Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- public class MercuryToursLogin {
- /**
- * @param args
- * @throws InterruptedException
- */
- public static void main(String[] args) throws InterruptedException {
- // Create a new instance of the Firefox driver
- // Notice that the remainder of the code relies on the interface,
- // not the implementation.
- System.setProperty("webdriver.gecko.driver", "C:\\\\geckodriver\\geckodriver.exe");
- WebDriver driver = new FirefoxDriver();
- String baseURL = "http://newtours.demoaut.com/";
- // Open browser using the defined base URL
- driver.get(baseURL);
- // Print out the title of the page. Should be "About us | Demoqa"
- System.out.println("Page title before is: " + driver.getTitle());
- // Find the text input element by its name
- WebElement user = driver.findElement(By.name("userName"));
- WebElement pass = driver.findElement(By.name("password"));
- WebElement login = driver.findElement(By.name("login"));
- user.sendKeys("tutorial");
- Thread.sleep(1000);
- pass.sendKeys("tutorial");
- Thread.sleep(1000);
- // Click on the About Us link
- login.click();
- // WebElement findFlight = driver.findElement(By.tagName(""));
- // WebElement findFlight = driver.getPageSource().contains("Flight Details");
- // String xpath = "html body div table tbody tr td table tbody tr td table tbody tr td table tbody tr td img";
- Thread.sleep(5000);
- String title = driver.getTitle();
- System.out.println("the title after login->> "+title);
- // if(driver.getPageSource().contains("Flight Finder")){
- // System.out.println("pass");
- // }else{
- // System.out.println("fail");
- // }
- //Close the browser
- driver.quit();
- }
- }
Add Comment
Please, Sign In to add comment