EChebanenko

Untitled

Oct 21st, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 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.chrome.ChromeDriver;
  5. import org.testng.annotations.BeforeTest;
  6. import org.testng.annotations.Test;
  7.  
  8. import java.util.concurrent.TimeUnit;
  9.  
  10. public class FirstTest {
  11.  
  12.  
  13.     @Test
  14.     public void testCurrentUrl() {
  15.         WebDriver driver = new ChromeDriver();
  16.         driver.manage().window().maximize();
  17.         driver.get("https://google.com.ua");
  18.         driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
  19.         WebElement searchInput = driver.findElement(By.xpath("//input[@class='gLFyf gsfi']"));
  20. //      WebElement searchInput = driver.findElement(By.xpath("/html/body/div[2]/div[2]/form/div[2]/div[1]/div[1]/div/div[2]/input"));
  21.         searchInput.click();
  22.         searchInput.sendKeys("java приколы");
  23.         WebElement searchingInput = driver.findElement(By.xpath("//center/input[@class='gNO89b']"));
  24. //      WebElement searchingInput = driver.findElement(By.xpath("/html/body/div[2]/div[2]/form/div[2]/div[1]/div[2]/div[2]/div[2]/center/input[1]"));
  25.         searchingInput.click();
  26.         WebElement firstLink = driver.findElement(By.xpath("//h3[@class='LC20lb DKV0Md']"));
  27.         firstLink.click();
  28.         driver.quit();
  29.  
  30.     }
  31. }
Add Comment
Please, Sign In to add comment