【发布时间】:2015-11-04 10:52:42
【问题描述】:
请打开这个网站-https://mobikwik.com/
有一个 Mobile 表单,其中第二项为 Select Operator。
我想使用 selenium webdriver 从此下拉列表中选择 - “创意”。
请帮忙。
另外,在选择想法后,我会得到一个新的下拉列表用于选择圆圈。需要选择孟买。
我的尝试:
driver.find_element_by_css_selector("li > span.ng-binding").click()
driver.find_element_by_xpath("//label[3]/i").click()
driver.find_element_by_css_selector("font > label > i").click()
driver.find_element_by_xpath("//section[@id='mainunit']/div/div[2]/div/div[2]/div/div/div/form/div[4]/p/dl/dd/ul/li[9]/span").click()
driver.find_element_by_xpath("//font/label[2]/i").click()
【问题讨论】:
-
试试这个
driver.find_element_by_xpath("//li[@class='ng-scope'][9]").click()。 -
要完成@JasonEstibeiro 的评论,首先尝试:
driver.find_element_by_xpath("//span[@class='ng-binding']").click()使选项可见,然后单击选项:driver.find_element_by_xpath("//li[@class='ng-scope'][9]").click() -
或者这似乎是一个更好的选择。试试看
driver.find_element_by_xpath("//span[@class='ng-binding' and text()='Idea'][1]").click()。让我知道它们是否有效。 -
两个选项都抛出相同的错误:
selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with看起来你必须先展开选项,然后再选择它。 -
@Javitronxo - 现在意识到了。我实际上已经手动点击了它(
ng-binding跨度)。无论如何,赞成你的答案。
标签: python selenium selenium-webdriver