小编use*_*305的帖子

Selenium元素不可见异常

我的任务是编写解析器来点击网站上的按钮,我只有点击其中一个按钮时遇到问题.以下代码适用于除一个按钮之外的每个按钮.

这是html:http: //pastebin.com/6dLF5ru8

这是源html:http: //pastebin.com/XhsedGLb

python代码:

 driver = webdriver.Firefox()  
 ...
 el = driver.find_element_by_id("-spel-nba")
 actions.move_to_element(el)
 actions.sleep(.1)
 actions.click()
 actions.perform()
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误.

ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Run Code Online (Sandbox Code Playgroud)

根据Saifur,我只是尝试使用相同的元素等待不可见的异常:

wait = WebDriverWait(driver, 10)
wait.until(EC.presence_of_element_located((By.XPATH, "//input[contains(@id,'spsel')][@value='nba']"))).click()
Run Code Online (Sandbox Code Playgroud)

python selenium

32
推荐指数
2
解决办法
8万
查看次数

标签 统计

python ×1

selenium ×1