“Element is not currently visible and so may not be interacted with” but another is?

前端 未结 5 1500
予麋鹿
予麋鹿 2020-12-16 04:01

I\'ve created another question which I think is the cause for this error: Why does the Selenium Firefox Driver consider my modal not displayed when the parent has overflow:h

5条回答
  •  温柔的废话
    2020-12-16 04:54

    In my case the element was already present in the page but it was disabled, so this didn't work (python):

    wait.until(lambda driver: driver.find_element_by_id("myBtn"))
    driver.find_element_by_id("myBtn").click()
    

    it failed with error:

    “Element is not currently visible and so may not be interacted with"
    

    To solve my problem, I had to wait a couple of seconds ( time.sleep(5) ) until the element became visible.

    You can also enable the element using JavaScript, a python example:

    driver.execute_script("document.getElementById('myBtn').disabled='' ")
    driver.execute_script("document.getElementById('myBtn').click() ")
    

提交回复
热议问题