Home > Software design >  Selenium - OpenQA.Selenium.ElementNotInteractableException: 'element not interactable
Selenium - OpenQA.Selenium.ElementNotInteractableException: 'element not interactable

Time:10-30

I'm trying to input text into a username field. It appears to find an element, however SendKeys() errors stating that the element is not interactable. I'm already waiting until the element exists, so I wouldn't think its related to waiting. Here is my code:

Console.WriteLine("Hello, World!");
ChromeDriver cd = new 
ChromeDriver(@"C:\Users\xxx\Downloads\chromedriver_win32\");
cd.Url = @"https://connect.ramtrucks.com/us/en/login";
cd.Navigate();

WebDriverWait wait = new WebDriverWait(cd,TimeSpan.FromSeconds(10));
IWebElement e = wait.Until(ExpectedConditions.ElementExists(By.ClassName("analytics-login-username")));

e.SendKeys("[email protected]");

Any suggestions would be much appreciated :)

CodePudding user response:

There are 2 thing you need to fix here:

  1. You are using locator that is not unique.
  2. You need to wait for element clickability, not just existence. I couldn't find element clickability case in C#, so element visibility can be used instead.
    So, instead of
IWebElement e = wait.Until(ExpectedConditions.ElementExists(By.ClassName("analytics-login-username")));

e.SendKeys("[email protected]");

Try this:

IWebElement e = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("input.analytics-login-username"))).SendKeys("[email protected]");
  • Related