Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I know this has been asked lots of times before but how do you get around the "element not interactable" exception?

I'm new to Selenium so excuse me if I get something wrong.

Here is my code:

button = driver.find_element_by_class_name(u"infoDismiss")
type(button)
button.click()
driver.implicitly_wait(10)

Here is the HTML:

<button class="dismiss infoDismiss">
    <string for="inplay_button_dismiss">Dismiss</string>
</button>

And here is the error message:

selenium.common.exceptions.ElementNotInteractableException: Message: 

After is says message there is literally nothing.

I have spent lots of time searching the web, not finding anything that solves my issue. I would really appreciate an answer.

Thanks in advance.

Edit: Changed "w" to driver so it is easier to read

Update: I have just realized that I've found the HTML of the wrong button! The real button HTML is below:

<button class="dismiss">
    <string for="exit">Dismiss</string>
</button>

Also, I've used the answers and comments and edited my code to look like this:

button = driver.find_element_by_css_selector("button.dismiss")
w.implicitly_wait(10)
ActionChains(w).move_to_element(button).click(button)

And now I get a new error:

selenium.common.exceptions.WebDriverException: Message: Tried to run command without establishing a connection

The error happens in line 1: button = driver.find_element_by_css_selector("button.dismiss")

Note: I really appreciate the help that has been given, thanks

question from:https://stackoverflow.com/questions/44119081/how-do-you-fix-the-element-not-interactable-exception

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
262 views
Welcome To Ask or Share your Answers For Others

1 Answer

A possibility is that the element is currently unclickable because it is not visible. Reasons for this may be that another element is covering it up or it is not in view, i.e. it is outside the currently view-able area.

Try this

from selenium.webdriver.common.action_chains import ActionChains

button = driver.find_element_by_class_name(u"infoDismiss")
driver.implicitly_wait(10)
ActionChains(driver).move_to_element(button).click(button).perform()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...