rajath_pai

2

Nov 13th, 2021 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebDriver;
  6. imoprt org.openqa.selenium.firefox.FirefoxDriver;
  7.  
  8.  
  9. public class mercury {
  10. public static void main(String[] args) {
  11.  
  12. Scanner sc = new Scanner(System.in);
  13. System.setProperty("webdriver.gecko.driver","/home/student/geckodriver");
  14.  
  15. System.out.print("Enter the expected title : ");
  16. String expected = sc.nextLine();
  17.  
  18. WebDrvier driver = new FirefoxDriver();
  19. driver.get("https://www.gmail.com");
  20.  
  21. if(driver.getTitle().equals(expected)) {
  22. System.out.println("Title Match");
  23. System.out.println(driver.getTitle());
  24.  
  25. driver.findElement(By.id("identifierId")).clear();
  26. driver.findElement(By.id("identifierId")).sendKeys("prabhuravindra1966@gmail.com");
  27. driver.findElement(By.id("identifierNext")).click();
  28.  
  29. try {
  30. Thread.sleep(5000);
  31. } catch(Exception e) {
  32. System.out.println("Exception occured");
  33. }
  34. driver.findElement(By.name("password")).sendKeys("4nm18cs124");
  35. driver.findElement(By.id("passwordNext")).click();
  36. System.out.println("PASS");
  37. } else {
  38. System.out.println("Title Mismatch");
  39. System.out.println("FAIL");
  40. }
  41. }
  42. }
Add Comment
Please, Sign In to add comment