Search code examples
javascriptseleniumwebdriverselenium-chromedriver

How to get password input field ID of gmail wiht selenium Webdriver?


The new JS enabled page of http://mail.google.com is making trouble to get ID of password input field. However, I've navigated from email ID page with its ID - identifierID .

How can I get the ID of password field?


Solution

  • Please find the updated code:

    Code:

        driver.manage().window().maximize();
        driver.get("http://www.gmail.c‌​om"); 
        WebElement elementid = driver.findElement(By.id("identifierId")); 
        elementid.sendKeys(""); 
        WebElement elementnxt = driver.findElement(By.id("identifierNext")); 
        elementnxt.click();
        WebDriverWait wait = new WebDriverWait(driver, 100);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@type='password']")));
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@type='password']")));
        WebElement elementpwd = driver.findElement(By.xpath("//input[@type='password']"));
        elementpwd.sendKeys("123");
    

    I have validated it on my end. Let me know if this doesn't work.