簡體   English   中英

Python Selenium WebDriver Chrome click()無法正常工作

[英]Python Selenium WebDriver Chrome click() is not working

請幫助...我無法單擊元素。

的HTML

圖片HTML

擴大后

圖片HTML2

My code
    clcik_on_privkey = driver.find_element_by_class_name("radio")
    Clcik_on_privkey = driver.find_element_by_name("331")
    clcik_on_privkey = driver.find_element_by_xpath("//input[@name='331']")
    clcik_on_privkey = driver.find_element_by_xpath("//label[10]")
    clcik_on_privkey = driver.find_element_by_css_selector(".radio:nth-child(11)")

搜索該項目沒有錯誤(有幾種方法),但是如果在任何情況下在endin上添加“ .click()”,都會出現錯誤

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <label aria-flowto="aria8" class="radio">...</label> is not clickable at point (286, 562). Other element would receive the click: <div class="alert popup alert-info animated-show-hide" style="bottom: 0px; z-index: 999;">...</div>
  (Session info: chrome=70.0.3538.77)
  (Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 6.1.7600 x86_64)
  <div class="alert popup alert-info animated-show-hide" style="bottom: 0px; z-index: 999;">

根據錯誤消息,上述元素正在獲得點擊。 這意味着上面的html層在您要單擊的單選按鈕上方。

如果您在單擊收音機之前已將其關閉,則可能需要等待看不見的聲音。 您試圖在警報彈出窗口消失之前單擊。

WebDriverWait(driver, 60).until(
        EC.invisibility_of_element_located((By.CSS_SELECTOR, 'div.alert.alert-info'))

然后點擊您的單選按鈕,

driver.find_element_by_xpath("//input[@name='331']")

暫無
暫無

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

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