Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. import com.sun.org.apache.bcel.internal.generic.Select;
  2. import org.openqa.selenium.By;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.chrome.ChromeDriver;
  6. import org.openqa.selenium.interactions.Actions;
  7. import org.testng.Assert;
  8. import org.testng.annotations.AfterTest;
  9. import org.testng.annotations.BeforeTest;
  10. import org.testng.annotations.Test;
  11.  
  12. import java.util.concurrent.TimeUnit;
  13.  
  14. public class addNewWordToDictionary {
  15.  
  16. protected static WebDriver driver;
  17.  
  18. @BeforeTest
  19. public void startChrome() {
  20. System.setProperty("webdriver.chrome.driver", "C:\\Users\\Анастасия\\Desktop\\Java for QA\\LR8\\chromedriver.exe");
  21. driver = new ChromeDriver();
  22.  
  23. driver.manage().window().maximize();
  24. driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
  25. }
  26.  
  27.  
  28. @Test(priority = 1, description = "Successful login into Lingualeo")
  29. public void SuccessfulLoginToLinguaLeo() {
  30. driver.get("https://lingualeo.com/ru/login");
  31. driver.findElement(By.xpath("//*[@id=\"email\"]")).sendKeys("adikalova@gmail.com");
  32. driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys("A771d6552");
  33. driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/div[1]/div[3]/form/input[4]")).click();
  34.  
  35. Assert.assertTrue(driver.getTitle().contains("Мои задания"), "Login is successful!");
  36. }
  37. @Test(priority = 2, description = "Add new world to dictionary")
  38. public void AddNewWordToDictionary(){
  39. driver.findElement(By.xpath("/html/body/div[2]/div[1]/div/div[1]/a")).click();
  40. driver.findElement(By.xpath("//*[@id=\"glossaryPage\"]/div[3]/div[2]/div[1]/div[2]/div/div/form/input")).sendKeys("dog");
  41. WebElement menu= driver.findElement(By.xpath("//*[@id=\"glossaryPage\"]/div[3]/div[2]/div[1]/div[2]/div/div/form/button")); //меню. Иконка из которой всё выпадает
  42. Actions mouse = new Actions(driver);
  43. //Двигаем мышь на меню и зависаем над ним. Меню вываливается.
  44. // mouse.moveToElement(menu).build().perform();
  45. mouse.moveToElement(menu).click().build().perform(); //- если надо кликнуть а не висеть над меню
  46.  
  47. //Кликаем по опции из списка.
  48. WebElement item= driver.findElement(By.cssSelector("div.transmenu__content > div:nth-of-type(1) > a.transword__text.t-ellps")); //Элемент меню из списка
  49. mouse.moveToElement(item).click().build().perform();
  50.  
  51. //или тут уже сам Webdriver может найти и кликнуть
  52. item.click();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement