简体   繁体   English

python和Selenium不一致的selenium.common.exceptions.TimeoutException

[英]Inconsistent selenium.common.exceptions.TimeoutException with Python and Selenium

I am getting an inconsistent TimeoutException when running a Selenium script. 运行Selenium脚本时,我收到不一致的TimeoutException。 If I step through the script using the PyCharm debugger, pausing at each line, the script runs successfully (assert passes, no TimeoutException). 如果我使用PyCharm调试器逐步执行脚本,则在每一行暂停,脚本将成功运行(声明传递,没有TimeoutException)。

However, when I run the script normally, I get a TimeoutException every time in the last wait.until(). 但是,当我正常运行脚本时,每次在最后一个wait.until()中都会得到一个TimeoutException。 I have read the documentation on EC.presence_of_element_located and I believe I'm using it correctly. 我已经阅读了EC.presence_of_element_located上的文档,并且相信自己使用正确。 Why am I getting this exception? 为什么我得到这个例外? Here's the code: 这是代码:

def test_if_special_diet_types_are_correct(self):
    wait = WebDriverWait(self.driver, 10)
    utils = Utils(self.driver, wait, self)
    utils.login()

    tab = self.driver.find_element_by_id("clients-tab")
    tab.click()

    list_item = wait.until(EC.presence_of_element_located((By.ID, '66')))
    list_item.click()

    edit_button = wait.until(EC.presence_of_element_located((By.ID, 'edit-client-button')))
    edit_button.click()

    element = wait.until(EC.presence_of_element_located((By.ID, 'client-input-first-name')))
    self.assertEqual('John', element.get_attribute('value'))

And here's the error: 这是错误:

Error
Traceback (most recent call last):
  File "/Users/jcleveland/projects/zippymeals/browser_tests/account.py", line 54, in test_if_special_diet_types_are_correct
EC.presence_of_element_located((By.ID, 'client-input-first-name')))
  File "/Users/jcleveland/projects/zippymeals/env/lib/python3.4/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

It would be a guess, but you might need to switch from presence_of_element_located to element_to_be_clickable here: 这将是一个猜测,但您可能需要在此处从presence_of_element_located为“ presence_of_element_located切换为“ element_to_be_clickable

list_item = wait.until(EC.element_to_be_clickable((By.ID, '66')))
list_item.click()

edit_button = wait.until(EC.element_to_be_clickable((By.ID, 'edit-client-button')))
edit_button.click()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PYTHON:Selenium 循环 selenium.common.exceptions.TimeoutException - PYTHON : Selenium loop selenium.common.exceptions.TimeoutException python selenium:selenium.common.exceptions.TimeoutException:消息:第20行 - python selenium : selenium.common.exceptions.TimeoutException: Message: line 20 消息:selenium.common.exceptions.TimeoutException - Message: selenium.common.exceptions.TimeoutException selenium.common.exceptions.TimeoutException:消息: - selenium.common.exceptions.TimeoutException: Message: 错误:selenium.common.exceptions.TimeoutException:消息: - error: selenium.common.exceptions.TimeoutException: Message: 引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息:使用Selenium Python - raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: using Selenium Python Python selenium:超时异常(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException:消息: - Python selenium : TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: 消息: - TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: selenium.common.exceptions.TimeoutException:使用 Selenium ZA7F1735426B93273 将文本发送到 iframe 中的用户名字段的消息错误 - selenium.common.exceptions.TimeoutException: Message error sending text to username field within iframe using Selenium Python selenium.common.exceptions.TimeoutException 错误使用 WebDriverWait 通过 Selenium 和 Python - selenium.common.exceptions.TimeoutException error using WebDriverWait with expected_conditions through Selenium and Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM