Created
October 25, 2015 15:39
-
-
Save yashaka/93ee429d997706828298 to your computer and use it in GitHub Desktop.
Tasj course lesson 5-2 - Implementing Precondition-helpers - Hints. Wait for JS on page load - notes_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Given impl hints | |
JS example: | |
localStorage.setItem("todos-troopjs", "[{\"completed\":true, \"title\":\"new\"}]") | |
Interface: | |
givenAllActive("a", "b", "c") | |
givenAllCompleted("a", "b", "c") | |
given(true, "a", "b", "c") | |
given(false, "a", "b", "c") | |
given("active", "a", "b", "c") (transform "active" to false via if or ternar operator) | |
given(active, "a", "b", "c") (~ as variable) | |
given(ACTIVE, "a", "b", "c") (~ as final "constant") | |
given(TaskType.ACTIVE, "a", "b", "c") (~ as value of ENUM type) | |
given(new Task("a", TaskType.ACTIVE), new Task("b", TaskType.COMPLETED)) | |
given(new Task("a", ACTIVE), new Task("b", COMPLETED)) | |
given(aTask("a", ACTIVE), aTask("b", COMPLETED)) | |
given( | |
aTask("a", ACTIVE), | |
aTask("b", COMPLETED)) | |
String operations | |
concatenation "Hello, " + name + "!"; | |
String.format String.format("Hellow, %s!", name); | |
StringBuilder new StringBuilder("Hellow, ").add(name).add("!"); | |
StringBuilder result = new StringBuilder("Hellow, "); | |
result.add(name); | |
result.add("!"); | |
return result; | |
BackSlashes "\n" -> new line | |
"\\n" -> \n | |
User for and ifs when needed | |
It's not a test logic implementation => You are free to use ifs and loops if needed. | |
Smart open with if | |
if (not $("...").is(visible)) => open page | |
Method Overloading | |
given( | |
aTask("a", ACTIVE), | |
aTask("b", ACTIVE)) | |
given("a", "b") | |
Wait for JS loading | |
http://barancev.github.io/page-loading-complete/ | |
http://barancev.github.io/how-selenium-waits-for-page-to-load/ | |
fixed version of todomvc: | |
https://todomvc4tasj.herokuapp.com/ | |
proper code change: | |
add: | |
$("#new-todo").shouldBe(enabled).setValue(text).pressEnter() | |
example of good frontend implementation: https://wishround.com/ua/ | |
with disabled UI while loading JS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment