SlideShare a Scribd company logo
1 of 109
Download to read offline
HtmlElements -
естественное расширение
PageObject

Кошелев Артём
Руководитель группы тестирования
                                   1
Кошелев Артём

Руководитель группы
тестирования



art.koshelev@yandex-team.ru
twitter: @art_koshelev




                              2
3
h"ps://github.com/yandex6qatools/htmlelements9
4
5
6
7
8
9
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

10
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

11
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

12
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

13
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

14
public class HomePageTest {
     ! @Test
     ! public void testSearchResults() {
     ! ! WebDriver driver = new FirefoxDriver();

     !   !   driver.get(“http://market.yandex.ru/”);
     !   !   driver.findElement(By.css(“input#search-input”))
     !   !   ! .sendKeys(“чикипибарум”);
     !   !   driver.findElement(By.css(“td.b-search__button”))
     !   !   ! .click();

     !   ! assertThat(“Не найдено что ничего не найдено”,
     !   ! driver.findElement(By.css(“p.no-found”)).getText(),
     !   ! is(“Заданным условиям не соответствует ни один товар”));
     !   }

15
16
17
18
19
20
21
public class HomePage extends PageObject {
     ! private WebDriver driver;

     ! @FindBy(css = “input#search-input”)
     ! private WebElement searchInput;

     ! @FindBy(css = “td.b-search__button”)
     ! private WebElement searchButton;

     ! public HomePage(WebDriver driver) {
     ! ! return PageFactory.initElements(driver, this.class);
     ! }
     ……



22
public class HomePage extends PageObject {
     ! private WebDriver driver;

     ! @FindBy(css = “input#search-input”)
     ! private WebElement searchInput;

     ! @FindBy(css = “td.b-search__button”)
     ! private WebElement searchButton;

     ! public HomePage(WebDriver driver) {
     ! ! return PageFactory.initElements(driver, this.class);
     ! }
     ……



23
public class HomePage extends PageObject {
     ! private WebDriver driver;

     ! @FindBy(css = “input#search-input”)
     ! private WebElement searchInput;

     ! @FindBy(css = “td.b-search__button”)
     ! private WebElement searchButton;

     ! public HomePage(WebDriver driver) {
     ! ! return PageFactory.initElements(driver, this.class);
     ! }
     ……



24
public class HomePage extends PageObject {
     ! private WebDriver driver;

     ! @FindBy(css = “input#search-input”)
     ! private WebElement searchInput;

     ! @FindBy(css = “td.b-search__button”)
     ! private WebElement searchButton;

     ! public HomePage(WebDriver driver) {
     ! ! return PageFactory.initElements(driver, this.class);
     ! }
     ……



25
public class HomePage extends PageObject {
     ! ……

     !   public SearchResultsPage lookFor(String item) {
     !   ! searchInput.type(item);
     !   ! searchButton.click();
     !   ! return new SearchResultsPage(driver);
     !   }

     !   public CatalogModelsPage clickOnElectronicLink() {
     !   ! electronikLink.click();
     !   ! return new CatalogModelsPage(driver);
     !   }

     ……!

26
public class HomePage extends PageObject {
     ! ……

     !   public SearchResultsPage lookFor(String item) {
     !   ! searchInput.type(item);
     !   ! searchButton.click();
     !   ! return new SearchResultsPage(driver);
     !   }

     !   public CatalogModelsPage clickOnElectronicLink() {
     !   ! electronikLink.click();
     !   ! return new CatalogModelsPage(driver);
     !   }

     ……!

27
public class HomePage extends PageObject {
     ! ……

     !   public SearchResultsPage lookFor(String item) {
     !   ! searchInput.type(item);
     !   ! searchButton.click();
     !   ! return new SearchResultsPage(driver);
     !   }

     !   public CatalogModelsPage clickOnElectronicLink() {
     !   ! electronikLink.click();
     !   ! return new CatalogModelsPage(driver);
     !   }

     ……!

28
HomePage onHomePage;
     SearchResultsPage onResultsPage;

     @Test
     public void canSearch() {
     ! onHomePage = new HomePage(driver).open();
     ! onResultsPage = onHomePage.lookFor(“чикипибарум”);

         assertThat(onResultsPage.errorMessage(), !        !
         ! is(“Заданным условиям не соответствует ни один товар.”));
     }




29
HomePage onHomePage;
     SearchResultsPage onResultsPage;

     @Test
     public void canSearch() {
     ! onHomePage = new HomePage(driver).open();
     ! onResultsPage = onHomePage.lookFor(“чикипибарум”);

         assertThat(onResultsPage.errorMessage(), !        !
         ! is(“Заданным условиям не соответствует ни один товар.”));
     }




30
HomePage onHomePage;
     SearchResultsPage onResultsPage;

     @Test
     public void canSearch() {
     ! onHomePage = new HomePage(driver).open();
     ! onResultsPage = onHomePage.lookFor(“чикипибарум”);

         assertThat(onResultsPage.errorMessage(), !        !
         ! is(“Заданным условиям не соответствует ни один товар.”));
     }




31
32
33
34
35
36
public class HomePage extends PageObject {

     ! @FindBy(css = “input#search-input”)
     ! private WebElement searchInput;

     ! @FindBy(css = “td.b-search__button”)
     ! private WebElement searchButton;




37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private WebElement searchInput;

     ! ! @FindBy(…)
     ! ! private WebElement searchButton;
     }




55
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private WebElement searchInput;

     ! ! @FindBy(…)
     ! ! private WebElement searchButton;
     }




56
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private WebElement searchInput;

     ! ! @FindBy(…)
     ! ! private WebElement searchButton;
     }




57
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private WebElement searchInput;

     ! ! @FindBy(…)
     ! ! private WebElement searchButton;
     }




58
59
@Block(@FindBy(…))
     public class SearchBlock extends HtmlElement {

     ! ! private SearchArrow arrow;
     ! ! private SearchTabs tabs;

     }




60
public class HomePage extends PageObject {


     ! ! public SearchArrow arrow;

     }




61
public class HomePage extends PageObject {

         @FindBy(xpath = “//different_locator”)
     ! ! public SearchArrow arrow;

     }




62
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private WebElement searchInput;

     ! ! @FindBy(…)
     ! ! private WebElement searchButton;
     }




63
64
@Block(@FindBy(…))
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(…)
     ! ! private TextInput searchInput;

     ! ! @FindBy(…)
     ! ! private Button searchButton;
     }




65
66
public class Link extends TypifiedElement {

     ! public Link(WebElement wrappedElement) {
     ! ! super(wrappedElement)
     ! }

         ......

     }



67
public class Link extends TypifiedElement {

         ......

     ! public void click() {…}

     ! public String getReference() {…}

     ! public String getText(){…}

     }
68
69
70
public class Range extends TypifiedElement {

     ! public Range(WebElement wrappedElement) {
     ! ! super(wrappedElement)
     ! }

     }




71
public class Range extends TypifiedElement {
     ! @FindBy(…)
     ! WebElement min;
     ! @FindBy(…)
     ! WebElement max;
     !
     ! public setRange(int min, int max) {…}

     ! public setMin(int min) {…}

         public setMax(int max) {…}
     }
72
73
74
75
76
77
public class HomePage extends PageObject {
     …

     ! @FindBy(css = “div.suggest”)
     ! private WebElement suggest;

     …




78
79
@Block(@FindBy(xpath = “div[@class*=‘search__arr’]”))
     @Name(“Поисковая стрела”)
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(xpath = “.//input”)
     ! ! @Name(“Поисковый запрос”)
     ! ! private TextInput searchInput;

     ! ! @FindBy(xpath = “.//input[@type=‘submit’]”)
     ! ! private Button searchButton;
     }


80
@Block(@FindBy(xpath = “div[@class*=‘search__arr’]”))
     @Name(“Поисковая стрела”)
     public class SearchArrow extends HtmlElement {
     ! ! @FindBy(xpath = “.//input”)
     ! ! @Name(“Поисковый запрос”)
     ! ! private TextInput searchInput;

     ! ! @FindBy(xpath = “.//input[@type=‘submit’]”)
     ! ! private Button searchButton;
     }


81
82
assertThat(actual, Matcher);




83
assertThat(str, is(“Everybody dance now!”));

     assertThat(year, lessThan(1999));

     assertThat(year, both(lessThan(1999)).
     ! ! ! ! ! and(greaterThan(1990)));




84
85
@FindBy(…)
     private WebElement firstSuggest;

     assertThat(firstSuggest, hasText(“canon”));




86
@FindBy(…)
     private WebElement firstSuggest;

     assertThat(firstSuggest, hasText(“canon”));




87
@FindBy(…)
     private WebElement firstSuggest;

     assertThat(firstSuggest, hasText(“canon”));




88
@FindBy(…)
     private List<WebElement> suggest;

     assertThat(suggest, hasItem(hasText(“canon”)));




89
@FindBy(…)
     private List<WebElement> suggest;

     assertThat(suggest, hasItem(hasText(“canon”)));




90
@FindBy(…)
     private List<WebElement> suggest;

     assertThat(suggest, hasItem(hasText(“canon”)));




91
@FindBy(…)
     private List<WebElement> suggest;

     assertThat(suggest, hasItem(hasText(“canon”)));




92
93
<dependency>

      <groupId>
        ru.yandex.qatools.htmlelements
      </groupId>
      <artifactId>
        htmlelements-java
      </artifactId>
      <version>1.9</version>

     </dependency>
94
95
96
97
98
@FindBy(…)
     private List<WebElement> suggest;

     assertThat(suggest, hasItem(hasText(“canon”)));




99
@FindBy(…)
      private List<WebElement> suggest;

      assertThat(suggest,
         withWaitFor(hasItem(hasText(“canon”))));




100
101
102
103
104
105
106
107
h"p://bit.ly/yqahegg0


      h"ps://github.com/yandex6qatools/htmlelements9
108
Кошелев Артём

Руководитель группы
тестирования



art.koshelev@yandex-team.ru
twitter: @art_koshelev




                              109

More Related Content

What's hot

[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testówFuture Processing
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuerygoldoraf
 
Jak zabít několik much jednou ranou přechodem na fragmenty
Jak zabít několik much jednou ranou přechodem na fragmentyJak zabít několik much jednou ranou přechodem na fragmenty
Jak zabít několik much jednou ranou přechodem na fragmentyDavid Vávra
 
Generic asynchronous HTTP utility for android
Generic asynchronous HTTP utility for androidGeneric asynchronous HTTP utility for android
Generic asynchronous HTTP utility for androidSomenath Mukhopadhyay
 

What's hot (7)

[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
[QE 2015] Mateusz Sulima - Kręta droga do dobrych testów
 
Get more votes!
Get more votes!Get more votes!
Get more votes!
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
 
Jak zabít několik much jednou ranou přechodem na fragmenty
Jak zabít několik much jednou ranou přechodem na fragmentyJak zabít několik much jednou ranou přechodem na fragmenty
Jak zabít několik much jednou ranou přechodem na fragmenty
 
Generic asynchronous HTTP utility for android
Generic asynchronous HTTP utility for androidGeneric asynchronous HTTP utility for android
Generic asynchronous HTTP utility for android
 
Best Fried Chicken
Best Fried ChickenBest Fried Chicken
Best Fried Chicken
 
1- Sourcecode Array
1- Sourcecode Array1- Sourcecode Array
1- Sourcecode Array
 

Viewers also liked

Advanced Automated Visual Testing
Advanced Automated Visual TestingAdvanced Automated Visual Testing
Advanced Automated Visual Testingadamcarmi
 
SeleniumCamp 2014 - Webdriver – the final frontier
SeleniumCamp 2014 - Webdriver – the final frontierSeleniumCamp 2014 - Webdriver – the final frontier
SeleniumCamp 2014 - Webdriver – the final frontierbkobos
 
Selenium and the Four Rules of Simple Design
Selenium and the Four Rules of Simple DesignSelenium and the Four Rules of Simple Design
Selenium and the Four Rules of Simple DesignTSundberg
 
SeleniumCamp 2015 Andrii Soldatenko
SeleniumCamp 2015 Andrii SoldatenkoSeleniumCamp 2015 Andrii Soldatenko
SeleniumCamp 2015 Andrii SoldatenkoAndrii Soldatenko
 
Practical continuous quality gates for development process
Practical continuous quality gates for development processPractical continuous quality gates for development process
Practical continuous quality gates for development processAndrii Soldatenko
 
SeleniumCamp 2016
SeleniumCamp 2016SeleniumCamp 2016
SeleniumCamp 2016Igor Khrol
 
Bullshit driven development
Bullshit driven developmentBullshit driven development
Bullshit driven developmentAndrei Solntsev
 
Типичные ошибки начинающих писать тесты на WebDriver
Типичные ошибки начинающих писать тесты на WebDriverТипичные ошибки начинающих писать тесты на WebDriver
Типичные ошибки начинающих писать тесты на WebDriverIgor Khrol
 
Selenium Tips & Tricks
Selenium Tips & TricksSelenium Tips & Tricks
Selenium Tips & TricksDave Haeffner
 

Viewers also liked (13)

Decorating Selenium
Decorating SeleniumDecorating Selenium
Decorating Selenium
 
Parallelization of Selenium tests with .NET/C# + NUnit
Parallelization of Selenium tests with .NET/C# + NUnitParallelization of Selenium tests with .NET/C# + NUnit
Parallelization of Selenium tests with .NET/C# + NUnit
 
Boost UI tests
Boost UI testsBoost UI tests
Boost UI tests
 
Advanced Automated Visual Testing
Advanced Automated Visual TestingAdvanced Automated Visual Testing
Advanced Automated Visual Testing
 
SeleniumCamp 2014 - Webdriver – the final frontier
SeleniumCamp 2014 - Webdriver – the final frontierSeleniumCamp 2014 - Webdriver – the final frontier
SeleniumCamp 2014 - Webdriver – the final frontier
 
Selenium and the Four Rules of Simple Design
Selenium and the Four Rules of Simple DesignSelenium and the Four Rules of Simple Design
Selenium and the Four Rules of Simple Design
 
SeleniumCamp 2015 Andrii Soldatenko
SeleniumCamp 2015 Andrii SoldatenkoSeleniumCamp 2015 Andrii Soldatenko
SeleniumCamp 2015 Andrii Soldatenko
 
Practical continuous quality gates for development process
Practical continuous quality gates for development processPractical continuous quality gates for development process
Practical continuous quality gates for development process
 
Step objects
Step objectsStep objects
Step objects
 
SeleniumCamp 2016
SeleniumCamp 2016SeleniumCamp 2016
SeleniumCamp 2016
 
Bullshit driven development
Bullshit driven developmentBullshit driven development
Bullshit driven development
 
Типичные ошибки начинающих писать тесты на WebDriver
Типичные ошибки начинающих писать тесты на WebDriverТипичные ошибки начинающих писать тесты на WebDriver
Типичные ошибки начинающих писать тесты на WebDriver
 
Selenium Tips & Tricks
Selenium Tips & TricksSelenium Tips & Tricks
Selenium Tips & Tricks
 

HtmlElements - естественное расширение PageObject

  • 1. HtmlElements - естественное расширение PageObject Кошелев Артём Руководитель группы тестирования 1
  • 3. 3
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 10
  • 11. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 11
  • 12. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 12
  • 13. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 13
  • 14. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 14
  • 15. public class HomePageTest { ! @Test ! public void testSearchResults() { ! ! WebDriver driver = new FirefoxDriver(); ! ! driver.get(“http://market.yandex.ru/”); ! ! driver.findElement(By.css(“input#search-input”)) ! ! ! .sendKeys(“чикипибарум”); ! ! driver.findElement(By.css(“td.b-search__button”)) ! ! ! .click(); ! ! assertThat(“Не найдено что ничего не найдено”, ! ! driver.findElement(By.css(“p.no-found”)).getText(), ! ! is(“Заданным условиям не соответствует ни один товар”)); ! } 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. public class HomePage extends PageObject { ! private WebDriver driver; ! @FindBy(css = “input#search-input”) ! private WebElement searchInput; ! @FindBy(css = “td.b-search__button”) ! private WebElement searchButton; ! public HomePage(WebDriver driver) { ! ! return PageFactory.initElements(driver, this.class); ! } …… 22
  • 23. public class HomePage extends PageObject { ! private WebDriver driver; ! @FindBy(css = “input#search-input”) ! private WebElement searchInput; ! @FindBy(css = “td.b-search__button”) ! private WebElement searchButton; ! public HomePage(WebDriver driver) { ! ! return PageFactory.initElements(driver, this.class); ! } …… 23
  • 24. public class HomePage extends PageObject { ! private WebDriver driver; ! @FindBy(css = “input#search-input”) ! private WebElement searchInput; ! @FindBy(css = “td.b-search__button”) ! private WebElement searchButton; ! public HomePage(WebDriver driver) { ! ! return PageFactory.initElements(driver, this.class); ! } …… 24
  • 25. public class HomePage extends PageObject { ! private WebDriver driver; ! @FindBy(css = “input#search-input”) ! private WebElement searchInput; ! @FindBy(css = “td.b-search__button”) ! private WebElement searchButton; ! public HomePage(WebDriver driver) { ! ! return PageFactory.initElements(driver, this.class); ! } …… 25
  • 26. public class HomePage extends PageObject { ! …… ! public SearchResultsPage lookFor(String item) { ! ! searchInput.type(item); ! ! searchButton.click(); ! ! return new SearchResultsPage(driver); ! } ! public CatalogModelsPage clickOnElectronicLink() { ! ! electronikLink.click(); ! ! return new CatalogModelsPage(driver); ! } ……! 26
  • 27. public class HomePage extends PageObject { ! …… ! public SearchResultsPage lookFor(String item) { ! ! searchInput.type(item); ! ! searchButton.click(); ! ! return new SearchResultsPage(driver); ! } ! public CatalogModelsPage clickOnElectronicLink() { ! ! electronikLink.click(); ! ! return new CatalogModelsPage(driver); ! } ……! 27
  • 28. public class HomePage extends PageObject { ! …… ! public SearchResultsPage lookFor(String item) { ! ! searchInput.type(item); ! ! searchButton.click(); ! ! return new SearchResultsPage(driver); ! } ! public CatalogModelsPage clickOnElectronicLink() { ! ! electronikLink.click(); ! ! return new CatalogModelsPage(driver); ! } ……! 28
  • 29. HomePage onHomePage; SearchResultsPage onResultsPage; @Test public void canSearch() { ! onHomePage = new HomePage(driver).open(); ! onResultsPage = onHomePage.lookFor(“чикипибарум”); assertThat(onResultsPage.errorMessage(), ! ! ! is(“Заданным условиям не соответствует ни один товар.”)); } 29
  • 30. HomePage onHomePage; SearchResultsPage onResultsPage; @Test public void canSearch() { ! onHomePage = new HomePage(driver).open(); ! onResultsPage = onHomePage.lookFor(“чикипибарум”); assertThat(onResultsPage.errorMessage(), ! ! ! is(“Заданным условиям не соответствует ни один товар.”)); } 30
  • 31. HomePage onHomePage; SearchResultsPage onResultsPage; @Test public void canSearch() { ! onHomePage = new HomePage(driver).open(); ! onResultsPage = onHomePage.lookFor(“чикипибарум”); assertThat(onResultsPage.errorMessage(), ! ! ! is(“Заданным условиям не соответствует ни один товар.”)); } 31
  • 32. 32
  • 33. 33
  • 34. 34
  • 35. 35
  • 36. 36
  • 37. public class HomePage extends PageObject { ! @FindBy(css = “input#search-input”) ! private WebElement searchInput; ! @FindBy(css = “td.b-search__button”) ! private WebElement searchButton; 37
  • 38. 38
  • 39. 39
  • 40. 40
  • 41. 41
  • 42. 42
  • 43. 43
  • 44. 44
  • 45. 45
  • 46. 46
  • 47. 47
  • 48. 48
  • 49. 49
  • 50. 50
  • 51. 51
  • 52. 52
  • 53. 53
  • 54. 54
  • 55. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private WebElement searchInput; ! ! @FindBy(…) ! ! private WebElement searchButton; } 55
  • 56. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private WebElement searchInput; ! ! @FindBy(…) ! ! private WebElement searchButton; } 56
  • 57. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private WebElement searchInput; ! ! @FindBy(…) ! ! private WebElement searchButton; } 57
  • 58. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private WebElement searchInput; ! ! @FindBy(…) ! ! private WebElement searchButton; } 58
  • 59. 59
  • 60. @Block(@FindBy(…)) public class SearchBlock extends HtmlElement { ! ! private SearchArrow arrow; ! ! private SearchTabs tabs; } 60
  • 61. public class HomePage extends PageObject { ! ! public SearchArrow arrow; } 61
  • 62. public class HomePage extends PageObject { @FindBy(xpath = “//different_locator”) ! ! public SearchArrow arrow; } 62
  • 63. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private WebElement searchInput; ! ! @FindBy(…) ! ! private WebElement searchButton; } 63
  • 64. 64
  • 65. @Block(@FindBy(…)) public class SearchArrow extends HtmlElement { ! ! @FindBy(…) ! ! private TextInput searchInput; ! ! @FindBy(…) ! ! private Button searchButton; } 65
  • 66. 66
  • 67. public class Link extends TypifiedElement { ! public Link(WebElement wrappedElement) { ! ! super(wrappedElement) ! } ...... } 67
  • 68. public class Link extends TypifiedElement { ...... ! public void click() {…} ! public String getReference() {…} ! public String getText(){…} } 68
  • 69. 69
  • 70. 70
  • 71. public class Range extends TypifiedElement { ! public Range(WebElement wrappedElement) { ! ! super(wrappedElement) ! } } 71
  • 72. public class Range extends TypifiedElement { ! @FindBy(…) ! WebElement min; ! @FindBy(…) ! WebElement max; ! ! public setRange(int min, int max) {…} ! public setMin(int min) {…} public setMax(int max) {…} } 72
  • 73. 73
  • 74. 74
  • 75. 75
  • 76. 76
  • 77. 77
  • 78. public class HomePage extends PageObject { … ! @FindBy(css = “div.suggest”) ! private WebElement suggest; … 78
  • 79. 79
  • 80. @Block(@FindBy(xpath = “div[@class*=‘search__arr’]”)) @Name(“Поисковая стрела”) public class SearchArrow extends HtmlElement { ! ! @FindBy(xpath = “.//input”) ! ! @Name(“Поисковый запрос”) ! ! private TextInput searchInput; ! ! @FindBy(xpath = “.//input[@type=‘submit’]”) ! ! private Button searchButton; } 80
  • 81. @Block(@FindBy(xpath = “div[@class*=‘search__arr’]”)) @Name(“Поисковая стрела”) public class SearchArrow extends HtmlElement { ! ! @FindBy(xpath = “.//input”) ! ! @Name(“Поисковый запрос”) ! ! private TextInput searchInput; ! ! @FindBy(xpath = “.//input[@type=‘submit’]”) ! ! private Button searchButton; } 81
  • 82. 82
  • 84. assertThat(str, is(“Everybody dance now!”)); assertThat(year, lessThan(1999)); assertThat(year, both(lessThan(1999)). ! ! ! ! ! and(greaterThan(1990))); 84
  • 85. 85
  • 86. @FindBy(…) private WebElement firstSuggest; assertThat(firstSuggest, hasText(“canon”)); 86
  • 87. @FindBy(…) private WebElement firstSuggest; assertThat(firstSuggest, hasText(“canon”)); 87
  • 88. @FindBy(…) private WebElement firstSuggest; assertThat(firstSuggest, hasText(“canon”)); 88
  • 89. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, hasItem(hasText(“canon”))); 89
  • 90. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, hasItem(hasText(“canon”))); 90
  • 91. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, hasItem(hasText(“canon”))); 91
  • 92. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, hasItem(hasText(“canon”))); 92
  • 93. 93
  • 94. <dependency> <groupId> ru.yandex.qatools.htmlelements </groupId> <artifactId> htmlelements-java </artifactId> <version>1.9</version> </dependency> 94
  • 95. 95
  • 96. 96
  • 97. 97
  • 98. 98
  • 99. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, hasItem(hasText(“canon”))); 99
  • 100. @FindBy(…) private List<WebElement> suggest; assertThat(suggest, withWaitFor(hasItem(hasText(“canon”)))); 100
  • 101. 101
  • 102. 102
  • 103. 103
  • 104. 104
  • 105. 105
  • 106. 106
  • 107. 107
  • 108. h"p://bit.ly/yqahegg0 h"ps://github.com/yandex6qatools/htmlelements9 108