簡體   English   中英

如何使用Selenium和Python單擊動態按鈕

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

我不知道如何單擊此動態按鈕,該按鈕沒有可用於單擊的HTML元素。

我試圖通過使用“ find_element_by_tag_name”單擊按鈕,但是它不起作用。 我在此處發布按鈕的代碼:

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

如果您知道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()

希望這對您有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM