×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Mihe Lanjelo
Added: Nov 30, 2016 1:50 PM
Modified: Dec 8, 2016 12:27 PM
Views: 17
Tags: no tags
  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.openqa.selenium.edge.EdgeDriver;
  6. import org.openqa.selenium.firefox.FirefoxDriver;
  7. import org.testng.annotations.AfterTest;
  8. import org.testng.annotations.BeforeClass;
  9.  
  10. import org.testng.annotations.BeforeTest;
  11. import org.testng.annotations.Test;
  12.  
  13. import java.util.concurrent.TimeUnit;
  14.  
  15.  
  16. public class SimpleTest {
  17.     public final String url = "http://rozetka.com.ua/";
  18.     public WebDriver driver;
  19.  
  20.  
  21.     @BeforeClass
  22.     public void setup() {
  23.         System.setProperty("webdriver.gecko.driver","C:\\Users\\mixan\\Downloads\\geckodriver\\geckodriver.exe");
  24.         System.setProperty("webdriver.chrome.driver","C:\\Users\\mixan\\Downloads\\chromedriver\\chromedriver.exe");
  25.         System.setProperty("webdriver.edge.driver","C:\\Users\\mixan\\Downloads\\MicrosoftWebDriver.exe");
  26.     }
  27.  
  28.     @Test
  29.     public void test() {
  30.         driver = new ChromeDriver();
  31.         driver.manage().window().maximize();
  32.         driver.get(url);
  33.  
  34. //        WebElement searchField = driver.findElement(By.cssSelector(".rz-header-search-input-text.passive"));
  35.         WebElement searchField = driver.findElement(By.xpath("//input[@class='rz-header-search-input-text passive']"));
  36.         searchField.clear();
  37.         searchField.sendKeys("IPhone 6");
  38.         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  39.  
  40.         WebElement searchButton = driver.findElement(By.cssSelector(".btn-link-i"));
  41.         searchButton.click();
  42.     }
  43.  
  44.     @AfterTest
  45.     public void testClose() throws Exception {
  46.         driver.close();
  47.     }
  48. }
  49.