Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/run-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous-Integration

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:
inputs:
browserName:
description: 'Browser type'
required: false
type: environment

jobs:
start-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Build with Maven
run: mvn clean

- name: Run tests
run: mvn verify

- uses: deblockt/cucumber-report-annotations-action@v1.7
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: "**/cucumber-report.json"


13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit-platform</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -93,7 +103,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<skip>false</skip>
<skip>true</skip>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/pom/pages/TodoListPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import java.util.List;

public class TodoListPage extends PageObject {

@FindBy(className = "new-todo")
private WebElement addItem;

@FindBy(id="list")
public List<WebElement> listOfSettings;

public void addTask(String item) {
addItem.sendKeys(item);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/runners/cucumber/TodoListTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty"},
plugin = {"pretty", "html:target/cucumber-reports.html"},
features = "src/test/resources/features/todomvc/add_new_items.feature",
glue = "runners.cucumber.stepdefinitions",
snippets = CucumberOptions.SnippetType.CAMELCASE
,tags = "@solo"
)
public class TodoListTestSuite {}
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
package runners.cucumber.stepdefinitions;

import io.cucumber.datatable.DataTable;
import io.cucumber.java.Before;
import io.cucumber.java.DataTableType;
import io.cucumber.java.ParameterType;
import io.cucumber.java.Transpose;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.screenplay.*;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.actions.Open;
import net.serenitybdd.screenplay.actors.OnStage;
import net.serenitybdd.screenplay.actors.OnlineCast;
import net.serenitybdd.screenplay.conditions.ConditionalPerformable;
import net.serenitybdd.screenplay.conditions.ConditionalPerformableOnQuestion;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.Convert;
import org.openqa.selenium.WebElement;
import pom.pages.TodoListPage;
import screenplay.model.Label;
import screenplay.questions.todolist.Items;
import screenplay.questions.travelocity.DepartureFlight;
import screenplay.tasks.todolist.AddAnItem;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import static net.serenitybdd.screenplay.GivenWhenThen.seeThat;
import static net.serenitybdd.screenplay.actors.OnStage.theActorInTheSpotlight;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class TodoStepDefinitions {

TodoListPage todoListPage;

@Before
public void setStage () {
OnStage.setTheStage(new OnlineCast());
Expand All @@ -41,7 +50,7 @@ public void stats_with_an_empty_list(Actor actor) {
);
}

@When("he adds {string} to his list")
@When("he adds {} to his list")
public void he_adds_to_his_list(String toDo) {
theActorInTheSpotlight().attemptsTo(
AddAnItem.called(toDo));
Expand All @@ -54,4 +63,61 @@ public void the_todo_list_should_contain(List<String> expectedItems) {
);
}

@Given("parameters are collected as map")
public void parametersAreCollectedAsMap(List<Map<String, String>> data) {
System.out.println("data processed is " + data);
}

@DataTableType()
public Map<String, String> convert(Map<String, String> parametersMap){
return parametersMap.entrySet()
.stream()
.map(TodoStepDefinitions::removeQuotesFromEntryValue)
.collect(HashMap::new,
(newMap, originalMap) -> newMap.put(originalMap.getKey(), nullIfEmpty(originalMap.getValue())),
HashMap::putAll
);
}

public static Map.Entry<String, String> removeQuotesFromEntryValue(Map.Entry<String, String> entry) {
return Map.entry(entry.getKey(), entry.getValue().replaceAll("\"", ""));
}

public static Map.Entry<String, String> replaceNullIfEmpty(Map.Entry<String, String> entry) {
return Map.entry(entry.getKey(), entry.getValue().replaceAll("", null));
}

/**
* Returns null if the input is empty.
*
* @param param The input string.
* @return The param or null if the input is empty.
*/
public static String nullIfEmpty(String param){
return !param.isEmpty() ? param : null;
}

@Given("parameters are collected as list")
public void parametersAreCollectedAsList(List<String> data) {
System.out.println(data);
}

@When("parameters are transposed in a list")
public void parametersAreTransposedAsList(@Transpose List<String> entry) {
System.out.println(entry);
}

@Then("the setting is available")
public void stepThree(DataTable settingsTable){
List<String> options = settingsTable.asList(String.class);
List<String> matchingOptions = settingsTable.asList(String.class);
SoftAssertions sa = new SoftAssertions();
sa.assertThat(matchingOptions)
.as("All options are available")
.containsExactlyInAnyOrderElementsOf(options);
sa.assertAll();
}



}
19 changes: 17 additions & 2 deletions src/test/resources/features/todomvc/add_new_items.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
Feature: Add new items

@solo
Scenario: Add items to an empty list
Given Toby starts with an empty list
When he adds "Buy some milk" to his list
When he adds Buy some milk to his list
Then the todo list should contain the following items:
| Buy some milk|
| Buy some milk|



Scenario: map input
Given parameters are collected as map
|header1|header2|header3|header4|
|"value1" |"value2" |"value3" | "" |
And parameters are collected as list
|header1|
|value1 |
|value2 |
|value3 |
When parameters are transposed in a list
|header12|value4 |value5 |value6 |
6 changes: 3 additions & 3 deletions src/test/resources/serenity.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# WebDriver configuration
#
webdriver {
driver = chrome
driver = edge
autodownload = true
}
headless.mode = true
#headless.mode = true
#serenity.test.root = todomvc.features
#Set this property to have more finer control on how screenshots are taken: BEFORE_AND_AFTER_EACH_STEP
#FOR_EACH_ACTION, AFTER_EACH_STEP, FOR_FAILURES, DISABLED
Expand All @@ -21,7 +21,7 @@ chrome.switches = """--start-maximized;--remote-allow-origins=*;--test-type;--no


pages {
angular = "https://todomvc.com/examples/angularjs/#/",
angular = "https://todomvc.com/examples/angular/dist/browser/#/all",
booking ="https://www.travelocity.com/"

}
Loading