gpt4 book ai didi

python - 单击时的 Webdriver WebDriverException/TimeoutException

转载 作者:太空宇宙 更新时间:2023-11-03 18:22:50 27 4
gpt4 key购买 nike

我正在使用 webdriver 单击 iframe 中表单上的提交按钮。基本上:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys(Keys.RETURN)
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

我也尝试过:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("#submit-endslide").click()
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

和:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("#submit-endslide").submit()
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

我得到了:

Traceback (most recent call last):
File "test_ytplayer_smoke_form.py", line 198, in testSmallFormSubmission
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys(Keys.RETURN)
File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 293, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing})
File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 370, in _execute
return self._parent.execute(command, params)
File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 166, in execute
self.error_handler.check_response(response)
File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
TimeoutException: Message: u'Selenium took too long to run your command.

然后WebDriverException:消息:u'由于之前的错误,此作业已完成。

无论我选择哪种方法,点击提交按钮时总会出现超时;(我已经尝试将超时增加到 300)

注意:当我观看测试运行时,正在单击提交按钮并打开一个新选项卡,但由于异常,测试永远不会通过。

最佳答案

似乎是 Chrome V28 浏览器特定问题导致了此问题;我更新到最新的浏览器版本 Chrome V35,这个问题似乎已解决

关于python - 单击时的 Webdriver WebDriverException/TimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23793604/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com