julia_v_iluhina

Untitled

Sep 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.98 KB | None | 0 0
  1. /*
  2.     предлагаю чуть подравнять сообщения в toString() для кондишенов
  3. */
  4.  
  5.   public static ExpectedCondition<WebElement> listElementHasText(final By elementsLocator, final String expectedText) {
  6. ...
  7.             public String toString() {
  8.                 return format("\n list by locator '%s' should contain element with text '%s'\n while actual list of elements contain texts:%s ",
  9.                         elementsLocator, expectedText, elementTexts);
  10.             }
  11. /*
  12.     for list located by [elementsLocator]
  13.     should contain element with text contains [expectedText]
  14.     while actual elements texts is [elementTexts]
  15. */
  16. ****************************************************************
  17.  
  18.     public static ExpectedCondition<WebElement> listElementHasExactText(final By elementsLocator, final String expectedText) {
  19. ...
  20.             public String toString() {
  21.                 return format("\n list by locator '%s' should contain element with exact text '%s'\n while actual list of elements contain texts:%s ",
  22.                         elementsLocator, expectedText, elementTexts);
  23.             }
  24. /*
  25.    for list located by [elementsLocator]
  26.    should contain element with text equals [expectedText]
  27.    while actual elements texts is [elementTexts]
  28. */
  29. ************************************************
  30.     public static ExpectedCondition<WebElement> listElementHasClass(final By elementsLocator, final String cssClass) {
  31. ...
  32.             public String toString() {
  33.                 //return format("\n element with class %s should exist. While actual classes are: %s ",
  34.                 //cssClass, elementClasses);
  35.                 //получилось еще страннее сообщение
  36.                 return format("\nelement of list located by '%s' in list located by %s should exist.\nwhile there are actual elements with locator by %s:",
  37.                         cssClass, elementsLocator, elementClasses);
  38.             }
  39. /*
  40.     list located by [elementsLocator]
  41.     should contain element with class [cssClass]
  42.     while actual elements classes is [elementClasses]
  43. */
  44. ***********************************
  45.     public static ExpectedCondition<Boolean> sizeOf(final By elementsLocator, final int expectedSize) {
  46.  ...
  47.             public String toString() {
  48.                 return format("\nsize of list: %s\n to be %s\n while actual size is %s\n", elements, expectedSize, listSize);
  49.             }
  50. /*
  51.     size of list located by [elementsLocator]
  52.     should be [expectedSize]
  53.     while actual size is [listSize]
  54. */
  55. *****************************************
  56.     public static ExpectedCondition<Boolean> sizeOfVisible(final By elementsLocator, final int expectedSize) {
  57. ....
  58.             public String toString() {
  59.                 return format("\n list of visible elements located by'%s'should have size '%s', " +
  60.                                 "but actual size of visible elements is '%s'\n texts of visible elements:'%s'",
  61.                         elementsLocator, expectedSize, listSize, elementTexts);
  62.             }
  63. /*
  64.   нас тут вообще не волнуют тексты элементов
  65.      потому не надо переменной elementTexts и работы с ней
  66.  
  67.     size of list of visible elements located by [elementsLocator]
  68.     should be [expectedSize]
  69.     while actual size is [listSize]
  70. */
  71. ************************************************************************
  72.  
  73.     public static ExpectedCondition<Boolean> minimumSizeOf(final By elementsLocator, final int expectedSize) {
  74. ...
  75.             public String toString() {
  76.                 return format("\nsize of list %s\n minimum size should be %s\n while actual size is %s\n",
  77.                         elements, expectedSize, currentSize);
  78.             }
  79. /*
  80.     size of list located by [elementsLocator]
  81.     should be at least [expectedSize]
  82.     while actual size is [listSize]
  83. */
  84. ******************************************************
  85.  
  86.     public static WebElement $(ExpectedCondition<WebElement> conditionToWaitParentElement, String innerElementCssSelector) {
  87.     public static WebElement $(ExpectedCondition<WebElement> conditionToWaitParentElement, By innerElementLocator) {
  88. /*
  89.     реализация методов  - ок
  90.     единственное - что стоит подправить -
  91.     в методе $(ExpectedCondition<WebElement> conditionToWaitParentElement, String innerElementCssSelector)
  92.     вызывать
  93.     $(ExpectedCondition<WebElement> conditionToWaitParentElement, By innerElementLocator)
  94.  
  95.     по сравнению с твоим вариантом - выигрыша в лаконичности практически не будет
  96.     но - так мы лучше обеспечим - что оба этих метода реализованы одинаково
  97. */
  98. **********************************************************
  99.         doubleClick($(listElementHasExactText(tasks, oldTaskText), ("label")));
  100.         return setValue($(listElementHasClass(tasks, "editing"), byCss(".edit")), newTaskText);
  101.  
  102.         или
  103.  
  104.         doubleClick($(listElementHasExactText(tasks, oldTaskText), "label"));
  105.         return setValue($(listElementHasClass(tasks, "editing"), ".edit"), newTaskText);
  106.  
  107. /*
  108.     технически - одно и то же
  109.     но - чуть меньше скобок
  110. */
  111. **************************************************************************
  112. $("#new-todo")
  113. /*
  114.     используется в 2-ух разных методах
  115.     https://docs.google.com/document/d/13dNyFGbI7mV22UUhH8E0LJ7SzabAmX7Bw7VCHScYfiU/edit#heading=h.pk1xvngaj4rk
  116.  
  117.     аналогично переменной By tasks
  118.     объяви и инициализируй переменную By newToDo
  119.     и далее ее используй
  120.  
  121. */
  122. **********************************************
  123.  $(listElementHasExactText(tasks, taskText), (".destroy")).click();
  124.  $(listElementHasExactText(tasks, taskText), (".toggle")).click();
  125.  
  126. /*
  127.     тут тоже на скобочках можно чуть сэкономить)
  128.     (".destroy") или ".destroy"
  129.     (".toggle")  или ".toggle"
  130. */
  131. ************************************************
  132. if ((getDriver().getCurrentUrl() != "https://todomvc4tasj.herokuapp.com"))
  133. /*
  134.     реализуй в ConciseAPI метод url() с реализацией
  135.     getDriver().getCurrentUrl()
  136.     а в пейдже  - вызывай его
  137.  
  138.     напоминаю - строки сравнивать с помощью знака != или == - бесполезно
  139.  
  140.         http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
  141.         http://www.javatpoint.com/string-comparison-in-java
  142.         http://alvinalexander.com/java/edu/qanda/pjqa00001.shtml
  143.  
  144. */
  145. ***************************
  146. getDriver().navigate().refresh();
  147.  
  148. /*
  149.     реализуй в ConciseAPI метод refresh()
  150.     с такой реализацией
  151.     а в пейдже - вызывай его
  152. */
Advertisement
Add Comment
Please, Sign In to add comment