Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. QA Testing
  3. Question
QA Testing

How can the "Element Not Interactable Exception" in Selenium be handled while performing web application automation?

Asked by Aashish Chaursiya Dec 1, 2024 807 views 1 answer
Share

About this question

In the following Selenium code, I am not able to send keys to the password field. I have clicked on the box, cleared it, and sent the keys but none if the options have worked. But when I am debugging the code and running it step by step it works fine as expected.

public class TestMail {
    protected static WebDriver driver;
    protected static String result;

    @BeforeClass
    public static void setup() {
        System.setProperty("webdriver.gecko.driver", "D:\geckodriver.exe");
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @Test
    void Testcase1() {
        driver.get("http://mail.google.com");

        WebElement loginfield = driver.findElement(By.name("Email"));
        if (loginfield.isDisplayed()) {
            loginfield.sendKeys("ragesh@gmail.in");
        } else {
            WebElement newloginfield = driver.findElement(By.cssSelector("#identifierId"));
            newloginfield.sendKeys("ragesh@gmail.in");
        }

        driver.findElement(By.name("signIn")).click();
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

        WebElement pwd = driver.findElement(By.cssSelector("#Passwd"));
        pwd.click();
        pwd.clear();

        if (pwd.isEnabled()) {
            pwd.sendKeys("123");
        } else {
            System.out.println("Not Enabled");
        }
    }
}

Your answer

1 Answer

More QA Testing discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest QA Testing Blogs

Guides, tips and career advice on QA Testing from JanBask experts.