ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Selenium 파이썬 요소가 상호 작용할 수 없음 오류
    카테고리 없음 2020. 8. 20. 21:18

    질문

    자동 등록 코드를 만들었지 만 작동하지 않습니다.클릭 할 대상입니다.

    <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)

    그리고 그것도 작동하지 않았다나는 이런 script로 그것을 시도하였습니다

    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()

    편집하다간단한 스크롤로 해결되었습니다. 이제 어떻게 자동으로 스크롤 할 수 있습니까?


    답변1

    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

    페이지에서 귀하의 button을 볼 수 있습니다.

    여기에 이미지 설명 입력



     

     

     

     

    출처 : https://stackoverflow.com/questions/61243840/selenium-python-element-not-interactable-error

    댓글

Designed by Tistory.