HtmlElements
PageObjects
StepsPageObjects
Tests StepsPageObjects
Рецепт приготовления
Вкусных тестов
PageObjects
public class SearchPage {    @FindBy(id = "text")    private WebElement requestInput;    @FindBy(xpath = "//input[@type=su...
Steps
public class CommonUserSteps {    public CommonUserSteps(WebDriver driver) {        ...    }    public SearchPage onSearch...
Tests
public class SearchResultsTest {    private WebDriver driver = new FirefoxDriver();    private CommonUserSteps user = new ...
Tests StepsPageObjects
Tests StepsPageObjects
Модель устройчива
Tests StepsPageObjects
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Шаблонизаторы
Загромождение
Загромождение
Загромождениеpublic class AutoHomePage {    @FindBy(name = "text")    private WebElement requestInput;    @FindBy(xpath = ...
Загромождение    public class AutoHomePage {        @FindBy(name = "text")        private WebElement requestInput;        ...
Загромождение      public class AutoHomePage {          @FindBy(name = "text")          private WebElement requestInput;  ...
Недостатки
Недостатки   Дублирование кода
Недостатки   Дублирование кода    Загромождение
Коронное блюдо
Tests  StepsPageObject Element
PageObject Element
HtmlElements
Блоки элементовТипизация элементовБиблиотека матчеров
Блоки элементовТипизация элементовБиблиотека матчеров
PageObject Element
Поисковая форма@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement {    @FindBy(id = ...
Форма авторизации@Block(@FindBy(className = "b-domik"))public class AuthorizationForm extends HtmlElement {    @FindBy(nam...
PageObject Element
Главная страницаpublic class SearchPage {    @FindBy(id = "text")    private WebElement requestInput;    @FindBy(xpath = "...
Главная страницаpublic class SearchPage {    private SearchArrow searchArrow;    private AuthorizationForm authorizationFo...
Структура страницы
Переопределениеpublic class AutoSearchPage {    @FindBy(className = "b-search")    private SearchArrow searchArrow;    pri...
Переопределениеpublic class SearchPage {    @FindBy(className = "b-search")    private SearchArrow searchArrow;}@Block(@Fi...
Блоки элементовТипизация элементовБиблиотека матчеров
Типизация
Типизация   GodeFest
Типизация   GodeFest
Поисковая форма     GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement {    ...
Поисковая форма     GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement {    ...
СтандартныеTextBlockTextInput Button  Link
РасширенныеCheckbox Radio        Form Select       Table
Checkboxpublic class Checkbox extends TypifiedElement {    public WebElement getLabel(){...}    public String getLabelText...
Radiopublic class Radio extends TypifiedElement {    public List<WebElement> getButtons(){...}    public WebElement getSel...
public class Select extends TypifiedElement {    public boolean isMultiple(){...}                                         ...
Formpublic class Form extends TypifiedElement {    public void fill(Map<String, Object> data){...}    public <T> void fill...
Formpublic class SearchPage {    @FindBy(className = "b-domik")    private Form authorizationForm;}public class CommonUser...
Tablepublic class Table extends TypifiedElement {    public List<WebElement> getHeadings(){...}    public List<String> get...
Tablepublic class SomeSecretePage {    @FindBy(className = "b-secret")    private Table users;}public class SearchUserStep...
Converters
Поисковая форма     GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement {    ...
Поисковая форма     GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement {    ...
Добавление элементовpublic class Suggest extends TypifiedElement {    public Suggest(WebElement wrappedElement) {        s...
Конструктор                СтраницаТипизированные элементы
Блоки элементовТипизация элементовБиблиотека матчеров
Матчеры
МатчерыassertThat(audience, isPayingAttention())
МатчерыassertThat(audience, isPayingAttention())assertThat(audience, is(not(sleeping())))
Матчеры элементов
Матчеры элементов  assertThat(element, exists())
Матчеры элементов      assertThat(element, exists())assertThat(element, hasText(“CodeFest”))
Матчеры элементов      assertThat(element, exists())assertThat(element, hasText(“CodeFest”))   assertThat(checkBox, isSele...
Матчеры элементов      assertThat(element, exists())assertThat(element, hasText(“CodeFest”))   assertThat(checkBox, isSele...
Матчеры в степахpublic class CommonUserSteps {    public void shouldSeeSearchResults() {       assertThat(          onSear...
Матчеры в степахpublic class CommonUserSteps {    public void shouldSeeSearchResults() {        assertThat(onSearchPage()....
Матчеры в степахpublic class CommonUserSteps {    public void shouldSeeSearchResults(Matcher mch) {        assertThat(    ...
Матчеры в тестах@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldSeeS...
Вывод ошибки@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldSeeSearc...
Именование элементов@Block(@FindBy(className = "b-head-search"))public class SearchResultBlock extends HtmlElement {    @N...
Переопределениеpublic class SearchPage {    @Name(“Блок поисковых результатов”)    private SearchResultsBlock searchResult...
Вывод ошибки@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldSeeSearc...
Декораторы
Waiter Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldSeeS...
Action Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldSeeS...
Condition Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() {    user.searchFor("CodeFest");    user.shouldS...
Блоки элементовТипизация элементовБиблиотека матчеров
Будущее   71
Библиотека элементов
Библиотека элементов
Генерация блоков
Генерация блоков Страница
Генерация блоков            @Block(@FindBy(className = "b-head-search"))              @Block(@FindBy(className = "b-head-s...
Попробуйте   сами
Tests  StepsPageObject Element
HtmlElements
Технологии    Converter = LambdaJ    Step FRWK = 2CDDs    Matchers = Hamcrest
@eroshenkoamhttps://github.com/yandex-qatools/htmlelementshttps://groups.google.com/forum/?fromgroups#!      forum/yandex-...
CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах
CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах
CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах
CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах
Upcoming SlideShare
Loading in …5
×

CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах

1,493 views
1,388 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,493
On SlideShare
0
From Embeds
0
Number of Embeds
386
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CodeFest 2013. Ерошенко А. — Фреймворк Html Elements или как удобно взаимодействовать с веб-интерфейсами в тестах

  1. 1. HtmlElements
  2. 2. PageObjects
  3. 3. StepsPageObjects
  4. 4. Tests StepsPageObjects
  5. 5. Рецепт приготовления
  6. 6. Вкусных тестов
  7. 7. PageObjects
  8. 8. public class SearchPage { @FindBy(id = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(name = "b-form-button__input") private WebElement authorizeButton; public SearchPage(WebDriver driver) { PageFactory.initElements(driver, this); } public void searchFor(String request) { requestInput.sendKeys(request); searchButton.click(); } public void authorize (String login, String password) { loginInput.sendKeys(login); passwordInput.sendKeys(login); authorizeButton.click(); }}
  9. 9. Steps
  10. 10. public class CommonUserSteps { public CommonUserSteps(WebDriver driver) { ... } public SearchPage onSearchPage() { return searchPage; } public void loginAsCommonUser() { User user = UserFactory.getCommonUser(); onSearchPage().authorize(user.getLogin, user.getPassword); } public void searchFor(String request) { onSearchPage().searchFor(request); } public void shouldSeeSearchResults() { assertTrue(onSearchPage().isSearchResultsBlockDisplayed()); }}
  11. 11. Tests
  12. 12. public class SearchResultsTest { private WebDriver driver = new FirefoxDriver(); private CommonUserSteps user = new CommonUserSteps(driver); @Before public void loadPage() { driver.get("http://www.yandex.ru"); } @Test public void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults(); } @After public void closeDriver() { driver.quit(); }}
  13. 13. Tests StepsPageObjects
  14. 14. Tests StepsPageObjects
  15. 15. Модель устройчива
  16. 16. Tests StepsPageObjects
  17. 17. Шаблонизаторы
  18. 18. Шаблонизаторы
  19. 19. Шаблонизаторы
  20. 20. Шаблонизаторы
  21. 21. Шаблонизаторы
  22. 22. Шаблонизаторы
  23. 23. Шаблонизаторы
  24. 24. Шаблонизаторы
  25. 25. Загромождение
  26. 26. Загромождение
  27. 27. Загромождениеpublic class AutoHomePage { @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "twoweeks") private WebElement rememberMeCheckBox; @FindBy(name = "text")
  28. 28. Загромождение public class AutoHomePage { @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "twoweeks") private WebElement rememberMeCheckBox; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton;
  29. 29. Загромождение public class AutoHomePage { @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "twoweeks") private WebElement rememberMeCheckBox; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(xpath = "//div[@class=b-domik__button]//input") private WebElement loginButton; @FindBy(name = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton;
  30. 30. Недостатки
  31. 31. Недостатки Дублирование кода
  32. 32. Недостатки Дублирование кода Загромождение
  33. 33. Коронное блюдо
  34. 34. Tests StepsPageObject Element
  35. 35. PageObject Element
  36. 36. HtmlElements
  37. 37. Блоки элементовТипизация элементовБиблиотека матчеров
  38. 38. Блоки элементовТипизация элементовБиблиотека матчеров
  39. 39. PageObject Element
  40. 40. Поисковая форма@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { @FindBy(id = "text") private WebElement requestInput; @FindBy(className = "b-form-button__input") private WebElement searchButton; public void searchFor(String request) { requestInput.sendKeys(request); searchButton.click(); }}
  41. 41. Форма авторизации@Block(@FindBy(className = "b-domik"))public class AuthorizationForm extends HtmlElement { @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(className = "b-form-button__input") private WebElement authorizeButton; public void authorize(String login, String pass) { loginInput.sendKeys(login); passwordInput.sendKeys(password); authorizeButton.click(); }}
  42. 42. PageObject Element
  43. 43. Главная страницаpublic class SearchPage { @FindBy(id = "text") private WebElement requestInput; @FindBy(xpath = "//input[@type=submit]") private WebElement searchButton; @FindBy(name = "login") private WebElement loginInput; @FindBy(name = "passwd") private WebElement passwordInput; @FindBy(name = "b-form-button__input") private WebElement authorizeButton; public SearchPage(WebDriver driver) { PageFactory.initElements(driver, this); } ...}
  44. 44. Главная страницаpublic class SearchPage { private SearchArrow searchArrow; private AuthorizationForm authorizationForm; public SearchPage(WebDriver driver) { HtmlElementLoader.populatePageObject(this, driver); } public void searchFor(String request) { searchArrow.searchFor(request); } public void login(String login, String password) { authorizationForm.login(login, password); }}
  45. 45. Структура страницы
  46. 46. Переопределениеpublic class AutoSearchPage { @FindBy(className = "b-search") private SearchArrow searchArrow; private SearchResultsBlock searchResultsBlock; public SearchResultsPage(WebDriver driver) { HtmlElementLoader.populatePageObject(this, driver); } public void searchFor(String request) { searchArrow.searchFor(request); } public boolean isSearchResultsBlockDisplayed() { return searchResultsBlock.isDisplayed(); }}
  47. 47. Переопределениеpublic class SearchPage { @FindBy(className = "b-search") private SearchArrow searchArrow;}@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { ...}
  48. 48. Блоки элементовТипизация элементовБиблиотека матчеров
  49. 49. Типизация
  50. 50. Типизация GodeFest
  51. 51. Типизация GodeFest
  52. 52. Поисковая форма GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { @FindBy(id = "text") private WebElement requestInput; @FindBy(className = "b-form-button__input") private WebElement searchButton; @FindBy(xpath = "//div[@class=i-popup__content]//li") private List<WebElement> suggest; public void searchBySuggest(String request, int suggestItemNumber) { requestInput.sendKeys(request); suggest.get(suggestItemNumber).click(); }}
  53. 53. Поисковая форма GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { @FindBy(id = "text") private WebElementrequestInput; TextInput requestInput; @FindBy(className = "b-form-button__input") private WebElement searchButton; Button searchButton; @FindBy(className = "i-popup__content") @FindBy(xpath = "//div[@class=i-popup__content]//li") private List<WebElement> suggest; Suggest suggest; public void searchBySuggest(String request, int suggestItemNumber) { requestInput.sendKeys(request); suggest.selectByIndex(suggestItemNumber); suggest.get(suggestItemNumber).click(); }}
  54. 54. СтандартныеTextBlockTextInput Button Link
  55. 55. РасширенныеCheckbox Radio Form Select Table
  56. 56. Checkboxpublic class Checkbox extends TypifiedElement { public WebElement getLabel(){...} public String getLabelText(){...} public String getText(){...} public void select(){...} public void deselect(){...} public void set(boolean checked){...} public boolean isSelected(){...}}
  57. 57. Radiopublic class Radio extends TypifiedElement { public List<WebElement> getButtons(){...} public WebElement getSelectedButton(){...} public void selectByValue(String value){...} public void selectByIndex(int index){...}}
  58. 58. public class Select extends TypifiedElement { public boolean isMultiple(){...} Select public List<WebElements> getOptions(){...} public List<WebElement> getAllSelectedOptions(){...} public WebElement getFirstSelectedOption(){...} public void selectByVisibleText(String text){...} public void selectByIndex(int index){...} public void selectByValue(String value){...} public void deselectAll(){...} public void deselectByValue(String value){...} public void deselectByIndex(int index){...} public void deselectByVisibleText(String text){...}}
  59. 59. Formpublic class Form extends TypifiedElement { public void fill(Map<String, Object> data){...} public <T> void fill(T bean, Converter Converter){...} protected WebElement findFiledByKey(String key){...} protected void fillField(WebElement e, Object value){...} public WebElement findFirstField(By by){...} public List<WebElement> findFields(By by){...} public List<WebElement> findSelectsBy(By by){...}}
  60. 60. Formpublic class SearchPage { @FindBy(className = "b-domik") private Form authorizationForm;}public class CommonUserSteps { public void loginAsCommonUser() { User user = UserFactory.getCommonUser(); HashMap<String, Object> userHash = convert(user); onSearchPage().getAuthorizationForm.fill(userHash); }}
  61. 61. Tablepublic class Table extends TypifiedElement { public List<WebElement> getHeadings(){...} public List<String> getHeadingsAsString(){...} public List<List<WebElement>> getRows(){...} public List<List<WebElement>> getColumns(){...} public WebElement getCellAt(int i, int j){...} public List<Map> getRowsMappedToHeadings() {...} public List<Map> getRowsMappedToHeadings(List<String> h){...} public List<Map> getRowsAsStringMappedToHeadings(){...} public List<Map> getRowsAsStringMappedToHeadings(List h){...}}
  62. 62. Tablepublic class SomeSecretePage { @FindBy(className = "b-secret") private Table users;}public class SearchUserSteps { public List<User> findAllUsers() { Table usersTable = onSomeSecretPage().getUsersTable(); List<Map> hash = usersTable.getRowsMappedToHeadings(); List<User> users = convert(hash); return users; }}
  63. 63. Converters
  64. 64. Поисковая форма GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { @FindBy(id = "text") private TextInput requestInput; @FindBy(className = "b-form-button__input") private Button searchButton; @FindBy(className = "i-popup__content") private Suggest suggest; public void searchBySuggest(String request, int suggestItemNumber) { requestInput.sendKeys(request); suggest.selectByIndex(suggestItemNumber); }}
  65. 65. Поисковая форма GodeFest@Block(@FindBy(className = "b-head-search"))public class SearchArrow extends HtmlElement { @FindBy(id = "text") private TextInput requestInput; @FindBy(className = "b-form-button__input") private Button searchButton; @FindBy(className = "i-popup__content") private Suggest suggest; public void searchBySuggest(String request, int suggestItemNumber) { requestInput.sendKeys(request); suggest.selectByIndex(suggestItemNumber); }}
  66. 66. Добавление элементовpublic class Suggest extends TypifiedElement { public Suggest(WebElement wrappedElement) { super(wrappedElement); } private List<WebElement> getItems() { return getWrappedElement().findElements(By.xpath("//li")); } public void selectByIndex(int itemIndex) { getItems().get(itemIndex).click(); } public void selectByValue(String itemValue) { for (WebElement item : getItems()) { if (itemValue.equals(item.getText())) { item.click(); return; } } throw new NoSuchElementException(); }}
  67. 67. Конструктор СтраницаТипизированные элементы
  68. 68. Блоки элементовТипизация элементовБиблиотека матчеров
  69. 69. Матчеры
  70. 70. МатчерыassertThat(audience, isPayingAttention())
  71. 71. МатчерыassertThat(audience, isPayingAttention())assertThat(audience, is(not(sleeping())))
  72. 72. Матчеры элементов
  73. 73. Матчеры элементов assertThat(element, exists())
  74. 74. Матчеры элементов assertThat(element, exists())assertThat(element, hasText(“CodeFest”))
  75. 75. Матчеры элементов assertThat(element, exists())assertThat(element, hasText(“CodeFest”)) assertThat(checkBox, isSelected())
  76. 76. Матчеры элементов assertThat(element, exists())assertThat(element, hasText(“CodeFest”)) assertThat(checkBox, isSelected())assertThat(radio, hasSelectedButton(3))
  77. 77. Матчеры в степахpublic class CommonUserSteps { public void shouldSeeSearchResults() { assertThat( onSearchPage().getSearchResults(), exist() ); }}
  78. 78. Матчеры в степахpublic class CommonUserSteps { public void shouldSeeSearchResults() { assertThat(onSearchPage().getSearchResults(), both(exist()).and(isDisplayed())); }}
  79. 79. Матчеры в степахpublic class CommonUserSteps { public void shouldSeeSearchResults(Matcher mch) { assertThat( onSearchPage().getSearchResults(), mch ); }}
  80. 80. Матчеры в тестах@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( both(exists()).and(isDisplayed()) );}
  81. 81. Вывод ошибки@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( both(exists()).and(isDisplayed()) );} Expected: element existing on page but: was <[[FirefoxDriver: firefox on MAC (e3b28f2e-7aa7- a241-8807-40df2a8e0b54)] -> ...]>
  82. 82. Именование элементов@Block(@FindBy(className = "b-head-search"))public class SearchResultBlock extends HtmlElement { @Name("Список поисковых результатов") @FindBy(id = "results") private List<SearchResult> searchResults; @FindBy(id = "info") private TextBlock searchInfo;}
  83. 83. Переопределениеpublic class SearchPage { @Name(“Блок поисковых результатов”) private SearchResultsBlock searchResultsBlock;}@Block(@FindBy(className = "b-head-search"))public class SearchResultsBlock extends HtmlElement { ...}
  84. 84. Вывод ошибки@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( both(exists()).and(isDisplayed()) );} Expected: element existing on page but: was SearchResultBlock
  85. 85. Декораторы
  86. 86. Waiter Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( should(exists()).whileWaitingUntil(timeoutHasExpired()) );} Expected: while waiting for [30000] ms element existing on page but: was SearchResultBlock
  87. 87. Action Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( should(exists()).after(pageRefresh(driver)) );} Expected: after page refresh element existing on page but: was SearchResultBlock
  88. 88. Condition Decorator@Testpublic void shouldSeeSearchResultsWhenLookingUp() { user.searchFor("CodeFest"); user.shouldSeeSearchResults( should(isDisplayed()).inCase(exists()); );} Expected: element displayed on page if element exists on page but: was SearchResultBlock
  89. 89. Блоки элементовТипизация элементовБиблиотека матчеров
  90. 90. Будущее 71
  91. 91. Библиотека элементов
  92. 92. Библиотека элементов
  93. 93. Генерация блоков
  94. 94. Генерация блоков Страница
  95. 95. Генерация блоков @Block(@FindBy(className = "b-head-search")) @Block(@FindBy(className = "b-head-search")) public class SearchArrow extends HtmlElement { @Block(@FindBy(className = "b-head-search")) public class SearchArrow extends HtmlElement { @FindBy(id = "text") @Block(@FindBy(className = "b-head-search")) public class SearchArrow extends HtmlElement { private class=SearchArrow extends HtmlElement { @FindBy(id "text") public WebElement requestInput; @Block(@FindBy(className = "b-head-search")) @FindBy(id = "text") private class SearchArrow extends HtmlElement { public WebElement requestInput; @FindBy(id = "text") private WebElement requestInput; @FindBy(className == "text") @FindBy(id "b-form-button__input") private WebElement requestInput; @FindBy(className = "b-form-button__input") private WebElement searchButton; private WebElement requestInput; @FindBy(className = "b-form-button__input") private WebElement searchButton; @FindBy(className = "b-form-button__input") private WebElement searchButton; public @FindBy(className searchButton; { private searchFor(String request) void WebElement = "b-form-button__input") public void searchFor(String request) { requestInput.sendKeys(request); private WebElement searchButton; public void searchFor(String request) { requestInput.sendKeys(request); searchButton.click(); public void searchFor(String request) { requestInput.sendKeys(request); searchButton.click(); } public void searchFor(String request) { requestInput.sendKeys(request); } searchButton.click(); } requestInput.sendKeys(request); searchButton.click(); } } } searchButton.click(); } } } } Страница Блоки
  96. 96. Попробуйте сами
  97. 97. Tests StepsPageObject Element
  98. 98. HtmlElements
  99. 99. Технологии Converter = LambdaJ Step FRWK = 2CDDs Matchers = Hamcrest
  100. 100. @eroshenkoamhttps://github.com/yandex-qatools/htmlelementshttps://groups.google.com/forum/?fromgroups#! forum/yandex-qatools-htmlelements qa-tools@yandex-team.ru

×