34

Here I have the image of my code and the image of my error. Can anyone help me to resolve this issue?

enter image description here

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Aarthi
  • 505
  • 1
  • 4
  • 10
  • 1
    You should try to isolate element you want to interact with. in your code there are multiple elements having tag; so its better if you use specific path to that element – Kushal Bhalaik May 09 '17 at 15:09
  • 13
    Please do not post images of text, rather keeping as text. – SiKing Aug 09 '17 at 22:18

6 Answers6

67

ElementNotInteractableException

ElementNotInteractableException is the W3C exception which is thrown to indicate that although an element is present on the HTML DOM, it is not in a state that can be interacted with.

Reasons & Solutions :

The reason for ElementNotInteractableException to occur can be numerous.

  1. Temporary Overlay of other WebElement over the WebElement of our interest :

    In this case, the direct solution would have been to induce ExplicitWait i.e. WebDriverWait in combination with ExpectedCondition as invisibilityOfElementLocated as folllows:

    WebDriverWait wait2 = new WebDriverWait(driver, 10);
    wait2.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("xpath_of_element_to_be_invisible")));
    driver.findElement(By.xpath("xpath_element_to_be_clicked")).click();
    

    A better solution will be to get a bit more granular and instead of using ExpectedCondition as invisibilityOfElementLocated we can use ExpectedCondition as elementToBeClickable as follows:

    WebDriverWait wait1 = new WebDriverWait(driver, 10);
    WebElement element1 = wait1.until(ExpectedConditions.elementToBeClickable(By.xpath("xpath_of_element_to_be_clicked")));
    element1.click();
    
  2. Permanent Overlay of other WebElement over the WebElement of our interest :

    If the overlay is a permanent one in this case we have to cast the WebDriver instance as JavascriptExecutor and perform the click operation as follows:

    WebElement ele = driver.findElement(By.xpath("element_xpath"));
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", ele);
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
3

I got this because the element I wanted to interact with was covered by another element. In my case it was an opaque overlay to make everything r/o.

When trying to click an element UNDER another element we usualy get "... other Element would receive the click " but not always :.(

2

This Exception we get when the element is not in an interactable state. So we can use wait till the element is Located or become clickable.

  1. Try using the Implicit wait:

    driver.manage().timeouts().implicitlyWait(Time, TimeUnit.SECONDS);
    
  2. If this is not working use Explicit wait:

    WebDriverWait wait=new WebDriverWait(driver, 20);
    WebElement input_userName;
    input_userName = wait.until(ExpectedConditions.elementToBeClickable(By.tagName("input")));
    input_userName.sendkeys("suryap");
    

You can use ExpectedCondition.visibilityOfElementLocated() as well. You can increase the time, for example,

WebDriverWait wait=new WebDriverWait(driver, 90);
Robert Christopher
  • 4,940
  • 1
  • 20
  • 21
Apps Maven
  • 1,314
  • 1
  • 4
  • 17
0

Actually the Exception is Element Not Visible

The best practice is to use Implicit wait below driver Instantiation so it get sufficient time to find element throughout the exception

driver.get("http://www.testsite.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

Still facing issue as some element require more time. Use ExplicitWait for individual element to satisfy certain condition

In your case you are facing element not visible exception then use wait condition in following way-

WebDriverWait wait = new WebDriverWait(driver, 120);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.your_Elemetnt));
NarendraR
  • 7,577
  • 10
  • 44
  • 82
  • I also that one also. But it doesn't work. Could you please tell me some other way to solve this issue? – Aarthi May 10 '17 at 11:18
  • Implicit wait is not a best practice. In fact it's use is recommended against by the Selenium contributors. Also mixing implicit and explicit waits is warned against in the official docs. – JeffC Nov 04 '17 at 03:56
  • Wait is not a solution... in my case i need to click on ant UI time picker component. Waiting is not a solution and im still looking for workaround – user1767083 Jul 16 '20 at 17:03
  • @user1767083 Obviously wait is not a solution for each problem. Post a separate question with appropriate details on SO. You will definitely get a solution. Thanks – NarendraR Jul 16 '20 at 18:04
  • @NarendraR this is the problem i face, https://stackoverflow.com/questions/62907372/compound-class-names-not-permitted-selenium-java/62907552#62907552 – user1767083 Jul 17 '20 at 07:51
  • @user1767083, Is there any similarity in your question and in this question ? Both questions are completely different. Where did you put the wait ? and come to know that _`wait is not a solution`_ ? – NarendraR Jul 17 '20 at 07:57
  • @NarendraR I have change the locator strategy and then i met error describe in this thread. There after I have tried given solutions. but it was not the solution. still i looking for solution. – user1767083 Jul 18 '20 at 08:11
0

A solution to this for Javascript looks like this. You will have to modify the time to suit your need.

driver.manage().setTimeouts({ implicit: 30000 });

Hope this is helpful to someone. see the docs for reference

tutug
  • 421
  • 4
  • 5
  • 3
    Never use sleep() or setTimeout() to wait for an event. It's a bad practice and you'll end up with a situation where your code randomly stops working when you deploy it on a new machine, but it was working perfectly until then. Events should be handled by waiting operations, designed to wake up your code as soon as the condition has been met or a timeout occurred. – Mladen B. Jun 14 '19 at 12:59
0

In my case issue was because there is some animation, and that element is not visible for some duration. And hence exception was occurring.

For some reason I couldn't make ExpectedConditions.visibilityOfElementLocated work, so I created a code to wait for some hardcoded seconds before proceeding.

from selenium.webdriver.support.ui import WebDriverWait


def explicit_wait_predicate(abc):
    return False


def explicit_wait(browser, timeout):
    try:
        Error = WebDriverWait(browser, timeout).until(explicit_wait_predicate)
    except Exception as e:
        None

And now I am calling this explicit_wait function wherever I want to wait for sometime e.g.

from selenium import webdriver
from selenium.webdriver.common.by import By


browser = webdriver.Safari()
browser.get('http://localhost')

explicit_wait(browser,5)   # This will wait for 5 secs
elem_un = browser.find_element(By.ID, 'userName')  
Sahil Doshi
  • 1,073
  • 10
  • 23