How to click next button while signing in yahoo mail?

Ravi :

I am trying to sign in to yahoo mail. Unable to proceed to click the "Next" button. I am not able to find out, where I am missing. Please guide me. Thank you.

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstScript {
    public static void main (String[] args) {
        System.setProperty("webdriver.chrome.driver","C:\\Selenium\\selenium-java-            3.141.59\\chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get("https://login.yahoo.com/");                                                                             driver.findElement(By.name("username")).sendKeys("[email protected]"); //name locator for text box
        WebElement searchIcon = driver.findElement(By.name("signin"));//name locator for next button
        searchIcon.click();
        driver.findElement(By.name("password")).sendKeys("testing"); //name locator for text box
        WebElement searchIcon2 =     driver.findElement(By.name("verifyPassword"));//name locator for next button
        searchIcon2.click();
    }
}
DebanjanB :

To send a character sequence first to the Email address field, invoke click() on the button with text as Next, send a character sequence to the Password field and again invoke click() on the button with text as Next, you need to induce WebDriverWait for the elementToBeClickable() and you can use the following Locator Strategies:

  • Code Block:

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    
    public class A_ChromeTest 
    {
        public static void main(String[] args) 
        {
            System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-maximized");
            options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
            options.setExperimentalOption("useAutomationExtension", false);
            WebDriver driver =  new ChromeDriver(options);
            driver.navigate().to("https://login.yahoo.com/");
            new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.phone-no#login-username"))).sendKeys("dev_pspl");
            driver.findElement(By.cssSelector("input#login-signin")).submit();
            new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("div#password-container>input"))).sendKeys("test123");
            ((JavascriptExecutor)driver).executeScript("arguments[0].click();", driver.findElement(By.xpath("//button[@id='login-signin']")));
        }
    }
    
  • Browser Snapshot:

yahoo_login

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=216727&siteId=1