这是我第一次在 stackoverflow 上发帖,我对 Selenium 和 Python 还有些陌生。
当 URL 等于 fx: https://www.example.com时,我不希望运行函数。
我在另一个讨论中读过 这个答案,但我不太明白发生了什么。
我希望您能抽出时间回答我的问题。
好的,所以我刚刚尝试过这个:
driver.get('https://www.google.com')
time.sleep(4)
driver.get('https://www.stackoverflow.com')
if WebDriverWait(driver, 10).until(EC.url_to_be('https://stackoverflow.com')):
print('Desired url was rendered within allocated time')
else:
print('Desired url was not rendered within allocated time')
Run Code Online (Sandbox Code Playgroud)
但这没有用。有任何想法吗?
控制台说
Traceback (most recent call last):
File "/Users/holger/PycharmProjects/waitTest/wait.py", line 15, in <module>
if WebDriverWait(browser, 10).until(EC.url_to_be('https://www.stackoverflow.com')):
File "/Users/holger/PycharmProjects/waitTest/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Run Code Online (Sandbox Code Playgroud)