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
To fix this, we can either apply explicit wait so that the webdriver waits for the expected condition - invisibilityOfElementLocated of the overlaying webelement. Or, we can apply the expected condition - elementToBeClickable on the webelement that we want to interact with.
The exception “Element is not clickable at point” might be thrown when the element is not under focus or the action is being performed on the incorrect WebElement. In such cases, you have to switch to the actual element and perform the click action.
NoSuchElementException Ideally, the exception occurs due to the use of incorrect element locators in the findElement(By, by) method. To handle this exception, use the wait command. Use Try/Catch to ensure that the program flow is interrupted if the wait command doesn't help.
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()
I just ran into a similar issue and was able to fix it by waiting until the button was "clickable".
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option('useAutomationExtension', False) browser = webdriver.Chrome('./chromedriver', options=chrome_options) browser.get(('YOURWEBSITEHERE.COM')) button = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.dismiss'))) button.click()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With