[英]selenium python element not interactable error
我制作了自動注冊的代碼,但它不起作用這是我點擊的目標
<div id="mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll" class="CheckBox" tabindex="-1" style="left: 878px; top: 669px; width: 89px; height: 28px;" role="checkbox" aria-label="전체동의 " aria-description="" aria-checked="true" status="focused" userstatus="selected" aria-selected="true"><div id="mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll:icontext" class="nexacontentsbox" style="left: 0px; top: 0px; width: 87px; height: 26px;"><img class="nexaiconitem" src="./_resource_/_theme_/esky_pc/images/btn_WF_CheS.png"><div class="nexatextitem" style="padding:0px 0px 0px 6px;display:inline-block;">전체동의</div></div></div>
我試過這段代碼
driver.find_element_by_xpath('//*[@id="mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll:icontext"]').click()
但它一直給我一個錯誤,我也試過這個
driver.find_element_by_xpath("//form[@class='mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll:icontext']]").send_keys(Keys.ENTER)
它也不起作用我試圖用這樣的腳本來做
element = driver.find_element_by_xpath("//form[@class='mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll:icontext']]")
driver.execute_script("arguments[0].click();", element)
它沒有給我一個錯誤,但它仍然無法點擊它我該如何解決這個問題?
whole code of my program
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import os
username = os.environ.get('USERNAME')
desktop = 'c:\\users\\' + username + '\\desktop\\'
driver = webdriver.Chrome(executable_path=desktop +"chromedriver.exe")
driver.get('https://www.ehaneul.go.kr:5443/esky_p/esky_index.jsp#MENU:M211002000')
sleep(3)
driver.find_element_by_xpath('//*[@id="mainframe.childframe.form.div_main.form.btn_M211000000"]').click()
browser = driver
sleep(2)
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
wait = WebDriverWait(driver, 3)
element =wait.until(EC.element_to_be_clickable((By.ID, "mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll")))
ActionChains(driver).move_to_element(element).click().perform()
編輯它用簡單的滾動解決。 所以現在,我怎樣才能自動滾動?
wait = WebDriverWait(driver, 10)
element =wait.until(EC.element_to_be_clickable((By.ID, "mainframe.childframe.form.div_main.form.div_work.form.chk_pricheckAll")))
ActionChains(driver).move_to_element(element).click().perform()
注意:請將以下導入添加到您的解決方案中
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
我可以在頁面上看到您的按鈕:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.