【发布时间】:2013-05-11 11:40:31
【问题描述】:
我正在尝试选择下拉列表的所有元素。
我正在测试的网站是:http://jenner.com/people
我试图访问的下拉列表(复选框列表)是“位置”列表。
我正在使用 Python。我收到以下错误:消息:u'Element 当前不可见,因此可能无法与之交互'
我使用的代码是:
from selenium import webdriver
url = "http://jenner.com/people"
driver = webdriver.Firefox()
driver.get(url)
page = driver.page_source
element = driver.find_element_by_xpath("//div[@class='filter offices']")
elements = element.find_elements_by_tag_name("input")
counter = 0
while counter <= len(elements) -1:
driver.get(url)
element = driver.find_element_by_xpath("//div[@class='filter offices']")
elements1 = element.find_elements_by_tag_name("input")
elements1[counter].click()
counter = counter + 1
我尝试了一些变体,包括在单击下拉选项之前单击初始元素,但均无效。关于如何使元素在 Selenium 中可见的任何想法。我花了最后几个小时在网上寻找答案。我看过一些关于在 Selenium 中移动鼠标的帖子,但还没有找到适合我的解决方案。
非常感谢。
【问题讨论】:
-
找出我不知道的python代码伙伴。让我知道它对你有用。
-
我会的。谢谢奥姆卡尔。你发帖后,我今天早上做了一些工作,今天晚些时候再做。今天有一些事情要做,然后我才能回去工作。
-
欧姆卡。你的解决方案对我不起作用。我已将其转换为 Python。我认为有两个问题。首先,我有同样的问题。其次,我没有从过滤器办公室到过滤器办公室打开这个报道。
-
点击“位置”后,班级名称从“过滤办公室”更改为“过滤办公室打开”该动态班级名称。
标签: python selenium visible mousemove invisible