【问题标题】:How do you locate and click on this button? Using python and selenium to web automate您如何找到并单击此按钮?使用 python 和 selenium 实现网络自动化
【发布时间】:2021-06-16 04:52:39
【问题描述】:

enter image description here

我在单击“立即注册”按钮时遇到问题,该按钮似乎与输入类型按钮不同。它也在使用 ng-click 并且不确定在多次尝试失败后如何单击按钮。

感谢您的帮助!

【问题讨论】:

  • 你试过什么?提示,使用按名称查找元素。看起来很简单
  • 能否提供更详细的复制代码以便我们提供帮助。

标签: python angularjs selenium selenium-webdriver web-scraping


【解决方案1】:

尝试复制 XPath,然后使用 driver.find_element_by_xpath(copied xpath) 函数定位元素,然后检查 this 输出 - 可能有助于单击。

【讨论】:

  • 我能够通过使用 ActionChains 和 XPATH 找到解决方案,a = driver.find_element_by_xpath("XPATH") action = ActionChains(driver) action.move_to_element(a).perform() driver .execute_script("arguments[0].click();", a) 感谢您的回复!
【解决方案2】:

你可以按JD2775所说的名字选择它,如果你想了解更多关于它的信息https://selenium-python.readthedocs.io/locating-elements.html

你可以试试

btn = driver.find_element_by_name('btnSignUp').click()

btn = driver.find_element_by_name('btnSignUp')
btn.click()

或者类似的东西

【讨论】:

  • 我刚刚通过另一种方法找到了解决方案,我相信我确实尝试按名称找到它,但它仍然不会点击。不过还是谢谢你的回复!
猜你喜欢
  • 2018-12-27
  • 1970-01-01
  • 2021-09-02
  • 1970-01-01
  • 2022-08-18
  • 1970-01-01
  • 2021-08-29
  • 1970-01-01
  • 2019-06-10
相关资源
最近更新 更多