简体   繁体   English

Python Selenium _ 错误:selenium.common.exceptions.TimeoutException

[英]Python Selenium _ Error: selenium.common.exceptions.TimeoutException

I'm studying how Selenium works.我正在研究 Selenium 的工作原理。 There are some elements that are fully loaded, but can't be clickable.有些元素已完全加载,但无法点击。 Here's the example of the case.这是案例的例子。 Selenium took a time until it is fully loaded. Selenium 需要一段时间才能完全加载。 Still the button is not clickable.按钮仍然不可点击。 I think Selenium can't find the element.我认为 Selenium 找不到该元素。 How can I resolve this issue?我该如何解决这个问题?

url url

https://www.google.co.kr/

button that I'm trying to click我试图点击的按钮

<a class="gb_A" aria-label="Google 앱" href="https://www.google.co.kr/intl/ko/about/products" aria-expanded="false" role="button" tabindex="0"><svg class="gb_Se" focusable="false" viewBox="0 0 24 24"><path d="M6,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,20c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM6,20c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM6,14c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,14c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM16,6c0,1.1 0.9,2 2,2s2,-0.9 2,-2 -0.9,-2 -2,-2 -2,0.9 -2,2zM12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,14c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,20c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z"></path></svg></a>

My code我的代码

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://www.google.co.kr/")
time.sleep(3)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='gbwa']/div/a/svg/path"))).click()

Error message错误信息

Traceback (most recent call last):
  File "C:\project\selenium test2.py", line 11, in <module>
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='gbwa']/div/a/svg/path"))).click()
  File "C:\project\venv\lib\site-packages\selenium\webdriver\support\wait.py", line 89, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 
wait=WebDriverWait(driver,20)
driver.get("https://www.google.co.kr/")
wait.until(EC.element_to_be_clickable((By.XPATH, "//a[@class='gb_A']/*[local-name()='svg']/*[local-name()='path']"))).click()

Seemed to work now just putting this to complete the question.现在似乎可以正常工作了,只需将其用于完成问题即可。 Was an issue with xpath identification. xpath 标识存在问题。

暂无
暂无

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

相关问题 Python Selenium _ 错误:selenium.common.exceptions.TimeoutException _ 与 WebDriverWait - Python Selenium _ Error: selenium.common.exceptions.TimeoutException _ with WebDriverWait 错误:selenium.common.exceptions.TimeoutException:消息: - error: selenium.common.exceptions.TimeoutException: Message: python和Selenium不一致的selenium.common.exceptions.TimeoutException - Inconsistent selenium.common.exceptions.TimeoutException with Python and Selenium python selenium:selenium.common.exceptions.TimeoutException:消息:第20行 - python selenium : selenium.common.exceptions.TimeoutException: Message: line 20 PYTHON:Selenium 循环 selenium.common.exceptions.TimeoutException - PYTHON : Selenium loop selenium.common.exceptions.TimeoutException selenium.common.exceptions.TimeoutException 使用 Selenium 和 Python 定位一个元素 - selenium.common.exceptions.TimeoutException locating an element using Selenium with Python 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 消息:selenium.common.exceptions.TimeoutException - Message: selenium.common.exceptions.TimeoutException selenium.common.exceptions.TimeoutException:消息: - selenium.common.exceptions.TimeoutException: Message:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM