【发布时间】:2026-02-10 23:00:01
【问题描述】:
我正在尝试使用以下代码执行此操作。它应该转到https://www.google.co.jp/ 并单击侧面菜单上的YouTube 链接。
import time
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\Firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
google=driver.get("https://www.google.co.jp/")
youtube=WebDriverWait(driver,300)
.until(EC.presence_of_element_located
((By.XPATH,".//*[@id='tsf']/div[2] /div[3]/center/input[2]")))
youtube.click()
它返回此错误:
[[ElementNotVisibleException]] ERROR
【问题讨论】:
-
语言没问题。你写的已经可以理解了。由于语法没问题,我对其进行了一些改进,并在开始时删除了道歉。祝你好运!