Selenium Webdriver Login Script

Selenium Webdriver login script

package selenium_examples;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;

public class example1 {

public static void main(String[] args)
   {

WebDriver driver = new FirefoxDriver();
driver.get("http://newtours.demoaut.com");
driver.findElement(By.name("userName")).sendKeys("mercury");
driver.findElement(By.name("password")).sendKeys("mercury");
driver.findElement(By.name("login")).click();
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
driver.findElement(By.name("findFlights")).click();
System.out.println("Done!");

}
    }

Above script Opens mercury tours website and logins into the site with given credentials.

and clicks on continue button(with the default values) in Find a Flight  page.


Implicit wait is used for waiting.




No comments:

Related Posts Plugin for WordPress, Blogger...