[英]How to get html element inside button?
<button type="button" name="abc" id="abc" class="bp" onmouseover="this.className = 'bp bph'" onmouseout="this.className = 'bp'" onclick="oCV_NS_.promptAction('finish')" style="font-family:"Arial";font-size:9pt">
<span tabindex="0">GENERATE REPORT</span>
</button>
我想單擊此按鈕並嘗試了一些代碼,但沒有任何嘗試:
driver.find_element_by_id("abc").click();
driver.find_element(By.ID, "abc")
element_by_name
也試過
請嘗試以下代碼並檢查按鈕是否不是 iframe 的一部分:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = webdriver.Chrome()
wait = WebDriverWait(browser, 10)
button= wait.until(EC.visibility_of_all_elements_located((By.ID, "abc")))
button.click()
嘗試使用以下xpath
:
driver.find_element_by_xpath("//button[@id='abc']/span").click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.