yohan sucipto yohan sucipto - 3 days ago 5
Javascript Question

my selenium wont open the url just open the firefox

Hi there ive been build a script to login to gmail but it wont type the password right after i entered the email

public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "E:\\Download\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier");
Thread.sleep(4000);
WebElement myElement = driver.findElement(By.id("Email"));
myElement.sendKeys("test@gmail.com");
driver.findElement(By.id("next")).click();
Thread.sleep(2000);
driver.findElement(By.id("Passwd"));
myElement.sendKeys("testing");
driver.findElement(By.id("signIn")).click();
}


Can anyone help me with this code?

Answer

Try this

    public static void main(String[] args) throws Exception {
    System.setProperty("webdriver.chrome.driver", "E:\\Download\\chromedriver_win32\\chromedriver.exe");
    WebDriver driver=new ChromeDriver();
    driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier");
    Thread.sleep(4000);
    WebElement myElement = driver.findElement(By.id("Email"));
    myElement.sendKeys("test@gmail.com");
    driver.findElement(By.id("next")).click();
    Thread.sleep(2000);
    WebElement myPassword = driver.findElement(By.id("Passwd"));
    myPassword.sendKeys("testing");
    driver.findElement(By.id("signIn")).click();
    }
Comments