在 python 上作業我需要你的幫助,了解如何根據里面的文本值單擊鏈接
<div class="wn-PreMatchItem wn-PreMatchItem_Selected " style="">
<div class="wn-ClassificationIcon ">
<div class="cis-ClassificationIconSmall cis-ClassificationIconSmall-1 "></div>
</div>
<span>Football</span>
</div>
我已經嘗試過這個,但它根本不起作用
driver.find_element(By.XPATH, "//span[text()='Football']")
你們能支持我嗎?
uj5u.com熱心網友回復:
在您的代碼中,您只是在搜索元素。您需要呼叫.click()才能實際單擊它:
driver.find_element(By.XPATH, "//span[text()='Football']").click()
如果這不起作用,您可以嘗試單擊其中一個div元素。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/457773.html
上一篇:美麗湯|無法遍歷div[js-content-images]類標簽
下一篇:使用python下載CSS和JS
