【发布时间】:2019-11-11 23:10:26
【问题描述】:
我正在尝试使用 Selenium 循环点击,
第一次点击有效,但第二次出现以下错误:
selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view
代码如下:
def send_keys_dropdown(self,url):
bot = self.bot
bot.get(url)
elements = bot.find_elements_by_xpath("//a[@data-tag='globalize']")
for elem in elements:
class_of_element = elem.get_attribute("class")
if class_of_element == 'CsLinkButton':
elem.click()
time.sleep(5)
# close icon
bot.find_element_by_xpath("//a[@data-tag='cmdCancel']").click()
如何在循环中单击这些元素?谢谢!
【问题讨论】:
-
尝试使用预期条件为“ElementToBeVisible”的 WebDriverWait。
-
如果您不能在代码中使用
elements引用,请查看here 以获得更多解释。还有一个问题,globalize' link disappear for the element once you click on theCancel` 链接有吗?
标签: python selenium automation