Advertisement
zhytnytskyi

TASK: Selenide and CSS/XPATH

Apr 15th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package ua.com.azhytnytskyi;
  2.  
  3. import com.codeborne.selenide.*;
  4. import org.junit.Test;
  5. import org.openqa.selenium.By;
  6.  
  7. import static com.codeborne.selenide.Selenide.*;
  8. import static com.codeborne.selenide.Selectors.*;
  9. import static com.codeborne.selenide.Condition.*;
  10. import static com.codeborne.selenide.CollectionCondition.*;
  11.  
  12. public class TodoMvcTest {
  13.  
  14.     {
  15.         System.setProperty("webdriver.chrome.driver", "C:/work/web drivers/chromedriver.exe");
  16.         Configuration.browser = "chrome";
  17.     }
  18.  
  19.     @Test
  20.     public void todoMvcTestCss() {
  21.         open("http://todomvc.com/examples/emberjs");
  22.  
  23.         $("#new-todo").setValue("a").pressEnter();
  24.         $("#new-todo").setValue("b").pressEnter();
  25.         $("#new-todo").setValue("c").pressEnter();
  26.  
  27.         $$("#todo-list li").shouldHave(exactTexts("a", "b", "c"));
  28.  
  29.         $("#todo-list>li:nth-of-type(2)").$(".toggle").click();
  30.  
  31.         $$("#todo-list>li.completed").shouldHave(exactTexts("b"));
  32.  
  33.         $$("#todo-list>li:not(.completed)").shouldHave(exactTexts("a","c"));
  34.     }
  35.  
  36.     @Test
  37.     public void todoMvcTestXPath(){
  38.         open("http://todomvc.com/examples/emberjs");
  39.  
  40.         $x("//input[@id='new-todo']").setValue("a").pressEnter();
  41.         $x("//input[@id='new-todo']").setValue("b").pressEnter();
  42.         $x("//input[@id='new-todo']").setValue("c").pressEnter();
  43.  
  44.         $$x("//ul[@id='todo-list']/li").shouldHave(exactTexts("a","b","c"));
  45.  
  46.         $x("//ul[@id='todo-list']/li[position()=2]/div/input").click();
  47.  
  48.         $$x("//ul[@id='todo-list']/li[contains(@class,'completed ember-view')]").shouldHave(exactTexts("b"));
  49.  
  50.         $$x("//ul[@id='todo-list']/li[not(contains(@class,'completed'))]").shouldHave(exactTexts("a","c"));
  51.        
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement