diff --git a/README.md b/README.md index 55d5241a..603ddc85 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ the [PageObject](http://martinfowler.com/bliki/PageObject.html) and the [Screenplay pattern](https://dzone.com/articles/page-objects-refactored-solid-steps-to-the-screenp), both implemented using the [Serenity BDD](http://serenity-bdd.info/#/) library and JUnit. -The web tests you'll find here run against the http://todomvc.com/examples/angularjs/#/ application and are organised +The web tests you'll find here run against the https://todomvc.com/examples/angular/dist/browser/#/all application and are organised by feature in packages under `src/test/java/net/serenitybdd/demos/todos//features`. By default the tests run on Chrome, so make sure you have the latest chromedriver instance on your system path. diff --git a/pom.xml b/pom.xml index df9bf338..b9706391 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 4.0.43 + 4.0.44 UTF-8 diff --git a/src/main/java/net/serenitybdd/demos/todos/pageobjects/pages/TodoListPage.java b/src/main/java/net/serenitybdd/demos/todos/pageobjects/pages/TodoListPage.java index 8d71d49a..935a178c 100644 --- a/src/main/java/net/serenitybdd/demos/todos/pageobjects/pages/TodoListPage.java +++ b/src/main/java/net/serenitybdd/demos/todos/pageobjects/pages/TodoListPage.java @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -@DefaultUrl("http://todomvc.com/examples/angularjs/#/") +@DefaultUrl("https://todomvc.com/examples/angular/dist/browser/#/all") public class TodoListPage extends PageObject { // ----------------------------------------------------------------------------------------------------------------- @@ -26,12 +26,12 @@ public class TodoListPage extends PageObject { private static final String NEW_TODO_INPUT_FIELD = ".new-todo"; private static final String ITEM_ROW = "//div[@class='view' and contains(.,'%s')]"; private static final String ITEM_ROW_LABEL = "//label[contains(.,'%s')]"; - private static final String COMPLETE_TICKBOX = ".//input[@ng-model='todo.completed']"; + private static final String COMPLETE_TICKBOX = ".toggle"; private static final String DELETE_BUTTON = "//button[@class='destroy']"; private static final String FILTERS = ".filters"; private static final String SELECTED_FILTER = ".filters li .selected"; private static final String ITEMS_LEFT_COUNT = ".todo-count strong"; - private static final String TOGGLE_ALL = "#toggle-all"; + private static final String TOGGLE_ALL = ".toggle-all"; private static final String CLEAR_COMPLETED = ".clear-completed"; // ----------------------------------------------------------------------------------------------------------------- @@ -98,7 +98,7 @@ public void clearCompletedItems() { } public void toggleAll() { - evaluateJavascript("arguments[0].click();",$("#toggle-all"), $(TOGGLE_ALL)); + evaluateJavascript("arguments[0].click();",$(".toggle-all"), $(TOGGLE_ALL)); } diff --git a/src/main/java/net/serenitybdd/demos/todos/pageobjects/steps/TodoUserSteps.java b/src/main/java/net/serenitybdd/demos/todos/pageobjects/steps/TodoUserSteps.java index 15344ae2..46d8be3c 100644 --- a/src/main/java/net/serenitybdd/demos/todos/pageobjects/steps/TodoUserSteps.java +++ b/src/main/java/net/serenitybdd/demos/todos/pageobjects/steps/TodoUserSteps.java @@ -136,17 +136,12 @@ public void should_see_that_displayed_items_do_not_contain(String... items) { @Step public void should_see_the_correct_website_title() { - assertThat(todoListPage.getTitle(), is("AngularJS • TodoMVC")); + assertThat(todoListPage.getTitle(), is("TodoMVC: Angular")); } @Step public void should_see_the_correct_application_heading() { - assertThat(todoListPage.heading(), is("todos")); - } - - @Step - public void should_see_the_about_section() { - assertThat(todoListPage.footer(), containsString("Credits")); + assertThat(todoListPage.heading(), is("Todos")); } } diff --git a/src/main/java/net/serenitybdd/demos/todos/screenplay/tasks/Start.java b/src/main/java/net/serenitybdd/demos/todos/screenplay/tasks/Start.java index 3d45c1c3..f177ccaa 100644 --- a/src/main/java/net/serenitybdd/demos/todos/screenplay/tasks/Start.java +++ b/src/main/java/net/serenitybdd/demos/todos/screenplay/tasks/Start.java @@ -9,6 +9,8 @@ import java.util.Arrays; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + public class Start { public static Performable withAnEmptyTodoList() { diff --git a/src/main/java/net/serenitybdd/demos/todos/screenplay/user_interface/TodoList.java b/src/main/java/net/serenitybdd/demos/todos/screenplay/user_interface/TodoList.java index 7616a963..4ef437e7 100644 --- a/src/main/java/net/serenitybdd/demos/todos/screenplay/user_interface/TodoList.java +++ b/src/main/java/net/serenitybdd/demos/todos/screenplay/user_interface/TodoList.java @@ -7,8 +7,8 @@ public class TodoList { public static final Target ITEMS = Target.the("List of todo items").locatedBy(".view label"); public static final Target ITEMS_LEFT = Target.the("Count of items left").locatedBy(".todo-count strong"); public static final Target TOGGLE_ALL_LABEL = Target.the("Toggle all items").locatedBy("[for='toggle-all']"); - public static final Target TOGGLE_ALL_BUTTON = Target.the("Toggle all items link").locatedBy("#toggle-all"); + public static final Target TOGGLE_ALL_BUTTON = Target.the("Toggle all items link").locatedBy(".toggle-all"); public static final Target CLEAR_COMPLETED = Target.the("Clear completed link").locatedBy(".clear-completed"); public static final Target FILTER = Target.the("filter by {0}").locatedBy("//a[.='{0}']"); public static final Target SELECTED_FILTER = Target.the("selected filter").locatedBy(".filters li .selected"); -} \ No newline at end of file +} diff --git a/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserActionSteps.java b/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserActionSteps.java new file mode 100644 index 00000000..bf818d6d --- /dev/null +++ b/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserActionSteps.java @@ -0,0 +1,38 @@ +package net.serenitybdd.demos.todos.cucumber.steps; + +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import net.serenitybdd.annotations.Steps; +import net.serenitybdd.demos.todos.pageobjects.model.TodoStatusFilter; +import net.serenitybdd.demos.todos.pageobjects.steps.TodoUserSteps; +import net.serenitybdd.screenplay.Actor; + +import java.util.List; + +public class TodoUserActionSteps { + + @Steps + TodoUserSteps james; + + @Given("Jane has prepared a todo list containing {items}") + public void that_James_has_an_empty_todo_list(List items) { + james.starts_with_a_todo_list_containing(items.toArray(new String[]{})); + } + + @And("he/she has completed the task called {string}") + public void sheHasCompletedTheTaskCalled(String task) { + james.completes(task); + } + + @When("she filters the list to show only {} tasks") + public void sheFiltersTheListToShowOnlyFilterTasks(String status) { + james.filters_items_to_show(TodoStatusFilter.valueOf(status)); + } + + @Then("her list should contain {items}") + public void herListShouldContain(List items) { + james.should_see_that_displayed_items_contain(items.toArray(new String[]{})); + } +} diff --git a/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserSteps.java b/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserSteps.java index 5a4997c8..9f172d85 100644 --- a/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserSteps.java +++ b/src/test/java/net/serenitybdd/demos/todos/cucumber/steps/TodoUserSteps.java @@ -20,6 +20,8 @@ import net.serenitybdd.screenplay.actors.OnStage; import net.serenitybdd.screenplay.actors.OnlineCast; import net.serenitybdd.screenplay.ensure.Ensure; +import net.serenitybdd.screenplay.matchers.WebElementStateMatchers; +import net.serenitybdd.screenplay.ui.Button; import net.serenitybdd.screenplay.waits.Wait; import java.util.List; @@ -29,6 +31,8 @@ import static net.serenitybdd.screenplay.GivenWhenThen.seeThat; import static net.serenitybdd.screenplay.actors.OnStage.setTheStage; import static net.serenitybdd.screenplay.actors.OnStage.theActorInTheSpotlight; +import static net.serenitybdd.screenplay.matchers.WebElementStateMatchers.isEnabled; +import static net.serenitybdd.screenplay.questions.WebElementQuestion.the; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.*; @@ -129,14 +133,13 @@ public void todo_list_should_contain(List expectedItems) { @Then("{actor}'s todo list should contain {items}") public void a_users_todo_list_should_contain(Actor actor, List expectedItems) { + actor.attemptsTo( - Wait.until(TheItems.displayed(), is(not(empty()))), + Wait.until(TheItems.displayed(), is(not(empty()))).forNoMoreThan(5).seconds(), Ensure.that(TheItems.displayed()).containsElementsFrom(expectedItems) - .withReportedError("Missing todos " + expectedItems) ); } - @Then("his/her todo list should be empty") public void todo_list_should_be_empty() { theActorInTheSpotlight().should(seeThat(TheItems.displayed(), equalTo(EMPTY_LIST))); diff --git a/src/test/java/net/serenitybdd/demos/todos/pageobjects/accessing_the_application/LearnAboutTheApplication.java b/src/test/java/net/serenitybdd/demos/todos/pageobjects/accessing_the_application/LearnAboutTheApplication.java index 074b365e..8d8acd57 100644 --- a/src/test/java/net/serenitybdd/demos/todos/pageobjects/accessing_the_application/LearnAboutTheApplication.java +++ b/src/test/java/net/serenitybdd/demos/todos/pageobjects/accessing_the_application/LearnAboutTheApplication.java @@ -25,7 +25,6 @@ public void should_be_able_to_identify_the_application_with_page_objects() { james.should_see_the_correct_website_title(); james.should_see_the_correct_application_heading(); - james.should_see_the_about_section(); } @Test diff --git a/src/test/java/net/serenitybdd/demos/todos/pageobjects/completing_todos/ExampleSteps.java b/src/test/java/net/serenitybdd/demos/todos/pageobjects/completing_todos/ExampleSteps.java deleted file mode 100644 index d2a2b2d3..00000000 --- a/src/test/java/net/serenitybdd/demos/todos/pageobjects/completing_todos/ExampleSteps.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.serenitybdd.demos.todos.pageobjects.completing_todos; - -import net.serenitybdd.annotations.Step; - -public class ExampleSteps { - - @Step("Page should contain [{0}] [{1}] element(s)") - public void pageShouldContainElements(Object value, Object name) { - - } -} diff --git a/src/test/java/net/serenitybdd/demos/todos/screenplay/accessing_the_application/LearnAboutTheApplication.java b/src/test/java/net/serenitybdd/demos/todos/screenplay/accessing_the_application/LearnAboutTheApplication.java index 84fe501e..fc56d07e 100644 --- a/src/test/java/net/serenitybdd/demos/todos/screenplay/accessing_the_application/LearnAboutTheApplication.java +++ b/src/test/java/net/serenitybdd/demos/todos/screenplay/accessing_the_application/LearnAboutTheApplication.java @@ -44,9 +44,8 @@ public void should_be_able_to_identify_the_application() { then(james).should( seeThat(Application.information(), - displays("title",equalTo("AngularJS • TodoMVC")), - displays("heading",equalTo("todos")), - displays("about", containsString("Credits")) + displays("title",equalTo("TodoMVC: Angular")), + displays("heading",equalTo("Todos")) ) ); } diff --git a/src/test/java/net/serenitybdd/demos/todos/screenplay/completing_todos/CompleteATodo.java b/src/test/java/net/serenitybdd/demos/todos/screenplay/completing_todos/CompleteATodo.java index 6c426f63..ab7ddded 100644 --- a/src/test/java/net/serenitybdd/demos/todos/screenplay/completing_todos/CompleteATodo.java +++ b/src/test/java/net/serenitybdd/demos/todos/screenplay/completing_todos/CompleteATodo.java @@ -41,7 +41,7 @@ public void jamesCanBrowseTheWeb() { @Test public void should_be_able_to_complete_a_todo_using_imperative_code() { - driver.get("http://todomvc.com/examples/angularjs/#/"); + driver.get("https://todomvc.com/examples/angular/dist/browser/#/all"); driver.findElement(By.cssSelector(".new-todo")).sendKeys("Walk the dog", Keys.ENTER); driver.findElement(By.cssSelector(".new-todo")).sendKeys("Put out the garbage", Keys.ENTER); driver.findElement( @@ -77,7 +77,7 @@ private TodoMVC(WebDriver driver) { } public void open() { - driver.get("http://todomvc.com/examples/angularjs/#/"); + driver.get("https://todomvc.com/examples/angular/dist/browser/#/all"); } public void enterTodoField(String todoName) { diff --git a/src/test/resources/features/cucumber/maintain_my_todo_list/completing_todos.feature b/src/test/resources/features/cucumber/maintain_my_todo_list/completing_todos.feature index feb49fe1..56148642 100644 --- a/src/test/resources/features/cucumber/maintain_my_todo_list/completing_todos.feature +++ b/src/test/resources/features/cucumber/maintain_my_todo_list/completing_todos.feature @@ -19,13 +19,15 @@ Feature: Completing todos Then her todo list should contain Walk the dog Scenario Outline: Completed tasks should be shown as Completed - Given Jane has a todo list containing Buy some milk, Walk the dog + Given Jane has a todo list containing When she completes the task called "Walk the dog" Then the "" task should be shown as Examples: - | Task | Final Status | - | Walk the dog | Completed | - | Buy some milk | Active | + | Initial Tasks | Task | Final Status | +# | | Walk the dog | Completed | + | Buy some milk, Walk the dog | Walk the dog | Completed | + | Walk the dog | Walk the dog | Completed | + | Buy some milk, Walk the dog | Buy some milk | Active | Scenario: The list of completed items should be empty if nothing has been completed Given Jane has a todo list containing Buy some milk, Walk the dog diff --git a/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_other_todos.feature b/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_other_todos.feature new file mode 100644 index 00000000..b5b7afc1 --- /dev/null +++ b/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_other_todos.feature @@ -0,0 +1,19 @@ +@cucumber +@filtering +Feature: Filtering other todos + + In order to make me feel a sense of accomplishment + As a forgetful person + I want to be to view all of things I have completed + + Scenario Outline: Filtering items by status + Given Jane has prepared a todo list containing + And she has completed the task called "" + When she filters the list to show only tasks + Then her list should contain + Examples: + | tasks | completed | filter | expected | + | Buy some milk, Walk the dog | Walk the dog | Active | Buy some milk | +# | Buy some milk, Walk the dog | Broken | Active | Buy some milk | + | Buy some milk, Walk the dog | Walk the dog | Completed | Walk the dog | + | Buy some milk, Walk the dog | Walk the dog | All | Buy some milk, Walk the dog | diff --git a/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_todos.feature b/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_todos.feature index 56697674..4e8979b7 100644 --- a/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_todos.feature +++ b/src/test/resources/features/cucumber/maintain_my_todo_list/filtering_todos.feature @@ -7,12 +7,13 @@ Feature: Filtering todos I want to be to view all of things I have completed Scenario Outline: Viewing the items by status - Given Jane has a todo list containing - And she completes the task called "Walk the dog" + Given Jane has a todo list containing + And she completes the task called "" When she filters her list to show only tasks Then her todo list should contain Examples: - | tasks | filter | expected | - | Buy some milk, Walk the dog | Active | Buy some milk | - | Buy some milk, Walk the dog | Completed | Walk the dog | - | Buy some milk, Walk the dog | All | Buy some milk, Walk the dog | + | tasks | completed | filter | expected | + | Buy some milk, Walk the dog | Walk the dog | Active | Buy some milk | +# | Buy some milk, Walk the dog | Broken | Active | Buy some milk | + | Buy some milk, Walk the dog | Walk the dog | Completed | Walk the dog | + | Buy some milk, Walk the dog | Walk the dog | All | Buy some milk, Walk the dog | diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties index b5b5e532..b7845f94 100644 --- a/src/test/resources/junit-platform.properties +++ b/src/test/resources/junit-platform.properties @@ -4,8 +4,8 @@ junit.jupiter.execution.parallel.enabled=true junit.jupiter.execution.parallel.config.strategy=fixed junit.jupiter.execution.parallel.mode.default = concurrent junit.jupiter.execution.parallel.mode.classes.default = concurrent -junit.jupiter.execution.parallel.config.fixed.parallelism=5 -junit.jupiter.execution.parallel.config.fixed.max-pool-size=5 +junit.jupiter.execution.parallel.config.fixed.parallelism=10 +junit.jupiter.execution.parallel.config.fixed.max-pool-size=10 # # Required to run Serenity Cucumber tests with JUnit 5 if you don't define this plugin in your runner class @@ -33,8 +33,8 @@ junit.jupiter.execution.parallel.config.fixed.max-pool-size=5 #---------------------------------------------------------- cucumber.execution.parallel.enabled=true cucumber.execution.parallel.config.strategy=fixed -cucumber.execution.parallel.config.fixed.parallelism=5 -cucumber.execution.parallel.config.fixed.max-pool-size=5 +cucumber.execution.parallel.config.fixed.parallelism=10 +cucumber.execution.parallel.config.fixed.max-pool-size=10 cucumber.plugin=io.cucumber.core.plugin.SerenityReporterParallel,pretty,timeline:target/test-results/timeline diff --git a/src/test/resources/serenity.conf b/src/test/resources/serenity.conf index a59051da..62624c5e 100644 --- a/src/test/resources/serenity.conf +++ b/src/test/resources/serenity.conf @@ -1,5 +1,5 @@ webdriver { - base.url = "http://todomvc.com/examples/angularjs/#/" + base.url = "https://todomvc.com/examples/angular/dist/browser/#/all" driver = chrome capabilities { browserName = "chrome" @@ -33,7 +33,7 @@ serenity { } // Default page configuration -home.page = "http://todomvc.com/examples/angularjs/#/" +home.page = "https://todomvc.com/examples/angular/dist/browser/#/all" environment = "prod,chrome" environments { @@ -41,7 +41,7 @@ environments { home.page = "http://localhost:8080/angularjs/#/" } prod { - home.page = "http://todomvc.com/examples/angularjs/#/" + home.page = "https://todomvc.com/examples/angular/dist/browser/#/all" } chrome { webdriver { @@ -87,7 +87,7 @@ environments { } } browserstack { - home.page = "http://todomvc.com/examples/angularjs/#/" + home.page = "https://todomvc.com/examples/angular/dist/browser/#/all" webdriver { driver = "remote" remote.url = "https://"${BROWSERSTACK_USER}":"${BROWSERSTACK_KEY}"@hub.browserstack.com/wd/hub" @@ -110,7 +110,7 @@ environments { } } saucelabs { - home.page = "http://todomvc.com/examples/angularjs/#/" + home.page = "https://todomvc.com/examples/angular/dist/browser/#/all" webdriver { driver = "remote" remote.url = "https://"${SAUCE_USERNAME}":"${SAUCE_ACCESS_KEY}"@ondemand.us-west-1.saucelabs.com:443/wd/hub" @@ -128,7 +128,7 @@ environments { } } lambdatest { - home.page = "http://todomvc.com/examples/angularjs/#/" + home.page = "https://todomvc.com/examples/angular/dist/browser/#/all" webdriver { driver = remote remote.url = "https://"${LT_USERNAME}":"${LT_ACCESS_KEY}"@hub.lambdatest.com/wd/hub"