Explain the process of solving the below encryption. org.openqa.selenium.ElementNotInteractableException: element not intractable?, C#

311    Asked by AndreaBailey in Cyber Security , Asked on Apr 21, 2022

driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");       
driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
Also I'm using ImplicitWait command, thread and still facing the issue

Answered by Anil Jha

There are multiple solutions to handle this blocker - selenium element not intractable :

Solution 1 - Use Javascript Executor :

driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");
// driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
IWebElement element = driver.findElement(By.XPath("//*[@id="btnSubmit"]"));
IJavaScriptExecutor JsExecutor = (IJavaScriptExecutor)driver;
JsExecutor.ExecuteScript("arguments[0].click();", element);
Solution 2 - Using Keyboard Events :
driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");
// driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
driver.findElement(By.XPath("//*[@id="btnSubmit"]")).sendKeys(Keys.Enter);
Solution 3 - Using Action class :
driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");
// driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
IWebElement element = driver.FindElement(By.XPath("//*[@id="btnSubmit"]"));
Actions builder = new Actions(driver);
builder.MoveToElement(element).Click().Perform();
Solution 4 - By Double Click the Submit button :
driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");
// driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
IWebElement element = driver.FindElement(By.XPath("//*[@id="btnSubmit"]"));
Actions builder = new Actions(driver);
builder.MoveToElement(element).DoubleClick().Perform();
Solution 5 - Using Coordinates [Least Preferred] :
driver.FindElement(By.Id("UserName")).SendKeys("test");
driver.FindElement(By.Id("Password")).SendKeys("test123");
// driver.FindElement(By.XPath("//*[@id="btnSubmit"]")).Click();
IWebElement element = driver.FindElement(By.XPath("//*[@id="btnSubmit"]"));
Actions builder = new Actions(driver);
builder.move_by_offset(X coordinates, Y coordinates).click().perform()
where 'X' & 'Y' coordinates should be known.


Your Answer

Interviews

Parent Categories