Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement;
  4. import org.openqa.selenium.firefox.FirefoxDriver;
  5.  
  6. public class Gmail_Login {
  7. @param args
  8. public static void main(String[] args) {
  9.  
  10. // objects and variables instantiation
  11. WebDriver driver = new FirefoxDriver();
  12. String appUrl = "https://accounts.google.com";
  13.  
  14. // launch the firefox browser and open the application url
  15. driver.get(appUrl);
  16.  
  17. // maximize the browser window
  18. driver.manage().window().maximize();
  19.  
  20. // declare and initialize the variable to store the expected title of the webpage.
  21. String expectedTitle = " Sign in - Google Accounts ";
  22.  
  23. // fetch the title of the web page and save it into a string variable
  24. String actualTitle = driver.getTitle();
  25.  
  26. // compare the expected title of the page with the actual title of the page and print the result
  27. if (expectedTitle.equals(actualTitle))
  28. {
  29. System.out.println("Verification Successful - Thecorrect title is displayed on the web page.");
  30. }
  31. else
  32. {
  33. System.out.println("Verification Failed - Anincorrect title is displayed on the web page.");
  34. }
  35.  
  36. // enter a valid username in the email textbox
  37. WebElement username = driver.findElement(By.id("Email"));
  38. username.clear();
  39. username.sendKeys("TestSelenium");
  40.  
  41. // enter a valid password in the password textbox
  42. WebElement password = driver.findElement(By.id("Passwd"));
  43. password.clear();
  44. password.sendKeys("password123");
  45.  
  46. // click on the Sign in button
  47. WebElement SignInButton = driver.findElement(By.id("signIn"));
  48. SignInButton.click();
  49.  
  50. // close the web browser
  51. driver.close();
  52. System.out.println("Test script executed successfully.");
  53.  
  54. // terminate the program
  55. System.exit(0);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement