ElementNotInteractableException: Message: Element could not be scrolled into view while trying to click an element using Selenium and Python

前端 未结 3 843
無奈伤痛
無奈伤痛 2021-01-25 00:06

I have this code:

driver.switch_to.window(window_after)

try:
    myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, \'_eventId         


        
3条回答
  •  盖世英雄少女心
    2021-01-25 00:14

    This problem usually arises when the element you are trying to click is present on the page but it is not fully visible and the point where selenium tries to click is not visible.
    In this case, you can use javascript to click on the element, which actually operates directly on the html structure of the page.
    You can use it like:

    element = driver.find_element_by_name("_eventId_confirmed")
    driver.execute_script("arguments[0].click();", element)
    

提交回复
热议问题