简体   繁体   English

如何使用Selenium和Python单击动态按钮

[英]How to click dynamic button using Selenium and Python

I don't know how to click this dynamic button, which has no HTML element I can use to click. 我不知道如何单击此动态按钮,该按钮没有可用于单击的HTML元素。

I tried to Click the button by using 'find_element_by_tag_name' but it doesn't work. 我试图通过使用“ find_element_by_tag_name”单击按钮,但是它不起作用。 I post the Code of the button here: 我在此处发布按钮的代码:

<a href="https://www.facebook.com/n/?confirmemail.php&amp" style="color:#3b5998;text-decoration: none" target="_blank" tabindex="-1"rel="external"></a>

If you know the beginning of the href you can use in the XPath starts-with : 如果您知道href的开头,则可以在XPath starts-with

dynamic_button_xpath = "//a[starts-with(@href, 'https://www.facebook.com/n/?')]"
driver.find_element_by_xpath(dynamic_button_xpath).click()

Hope this helps you! 希望这对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM