diff --git a/README.md b/README.md
index c776008..2474eea 100644
--- a/README.md
+++ b/README.md
@@ -35,18 +35,16 @@
Before you can start performing Java automation testing with Serenity, you would need to:
-- Install the latest **Java development environment** i.e. **JDK 1.6 to JDK 1.8**.
-
-- Download the latest **Selenium Client** and its **WebDriver bindings** from the [official website](https://www.selenium.dev/downloads/). Latest versions of Selenium Client and WebDriver are ideal for running your automation script on LambdaTest Selenium cloud grid.
+- Install the latest **Java development environment**, and at least **JDK 1.8**.
- Install **Maven** which supports **JUnit** framework out of the box. **Maven** can be downloaded and installed following the steps from [the official website](https://maven.apache.org/). Maven can also be installed easily on **Linux/MacOS** using [Homebrew](https://brew.sh/) package manager.
### Cloning Repo And Installing Dependencies
-**Step 1:** Clone the LambdaTest’s Serenity-Selenium-Sample repository and navigate to the code directory as shown below:
+**Step 1:** Clone the Serenity-Selenium-Sample repository and navigate to the code directory as shown below:
```bash
-git clone https://github.com/LambdaTest/Serenity-Selenium-Sample
+git clone https://github.com/serenity-bdd/Serenity-Selenium-Sample.git
cd Serenity-Selenium-Sample
```
@@ -58,7 +56,8 @@ mvn versions:display-dependency-updates
### Setting Up Your Authentication
-Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=serenity-selenium-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login?utm_source=github&utm_medium=repo&utm_campaign=serenity-selenium-sample).
+Make sure you have your LambdaTest credentials with you to run test automation scripts.
+You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=serenity-selenium-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login?utm_source=github&utm_medium=repo&utm_campaign=serenity-selenium-sample).
**Step 2:** Set LambdaTest **Username** and **Access Key** in environment variables.
@@ -85,7 +84,7 @@ Feature: Google's Search Functionality
Then I should see title "LambdaTest - Google Search"
```
-Following below is the `GooglePage.java` file for the above Test Case Scenario.
+The page object the `GooglePage.java` file for the above Test Case Scenario.
```java title="GooglePage.java"
package com.lambdatest.cucumber.pages;
@@ -110,7 +109,8 @@ public class GooglePage extends PageObject {
public void searchForString(String searchString) {
search.sendKeys(searchString);
}
- public void submitForm() throws Exception {
+
+ public void submitForm() throws Exception {
searchButton.click();
Thread.sleep(5000);
}
diff --git a/pom.xml b/pom.xml
index 28531be..1f00f65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,47 +19,16 @@
${java.version}
UTF-8
- 2.0.48
- 2.0.67
- 1.9.37
+ 3.6.16
3.0.0-M3
3.0.0-M3
3.0.0-M2
3.8.0
- 10.0.2
- 10.0.2
-
-
-
- serenity
- bintray
- http://dl.bintray.com/serenity/maven
-
-
-
-
- serenity
- bintray-plugins
- http://dl.bintray.com/serenity/maven
-
-
-
-
- org.eclipse.jetty
- jetty-io
- ${jetty-io.version}
-
-
-
- org.eclipse.jetty
- jetty-util
- ${jetty-util.version}
-
net.serenity-bdd
@@ -71,25 +40,15 @@
serenity-junit
${serenity.version}
-
- net.serenity-bdd
- serenity-rest-assured
- ${serenity.version}
-
net.serenity-bdd
serenity-cucumber
- ${serenity.cucumber.version}
+ ${serenity.version}
org.slf4j
slf4j-simple
- 1.6.1
-
-
- org.codehaus.groovy
- groovy-all
- 1.8.6
+ 2.0.7
junit
@@ -112,24 +71,6 @@
-
- org.apache.maven.plugins
- maven-enforcer-plugin
- ${maven-enforcer-plugin.version}
-
-
- enforce
-
-
-
-
-
-
- enforce
-
-
-
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -154,8 +95,6 @@
com/lambdatest/cucumber/SingleTest.java
- true
- -Xmx1024m -XX:MaxPermSize=256m
@@ -189,54 +128,4 @@
-
-
-
- single
-
-
-
- maven-failsafe-plugin
- ${maven.failsafe-plugin.version}
-
-
- com/lambdatest/cucumber/SingleTest.java
-
- true
- -Xmx1024m -XX:MaxPermSize=256m
-
- single
- MY_TEST_SCHEMA_${surefire.forkNumber}
-
-
-
-
-
-
-
-
- parallel
-
-
-
- maven-failsafe-plugin
- ${maven.failsafe-plugin.version}
-
-
- com/lambdatest/cucumber/Parallel*.java
-
- classes
- 10
- 10
- true
- -Xmx1024m -XX:MaxPermSize=256m
-
- parallel_${surefire.forkNumber}
-
-
-
-
-
-
-
diff --git a/src/test/java/com/lambdatest/LambdaTestSerenityDriver.java b/src/test/java/com/lambdatest/LambdaTestSerenityDriver.java
deleted file mode 100644
index ccc7673..0000000
--- a/src/test/java/com/lambdatest/LambdaTestSerenityDriver.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.lambdatest;
-
-import java.net.URL;
-import java.util.Iterator;
-
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.remote.RemoteWebDriver;
-
-import net.thucydides.core.util.EnvironmentVariables;
-import net.thucydides.core.util.SystemEnvironmentVariables;
-import net.thucydides.core.webdriver.DriverSource;
-
-public class LambdaTestSerenityDriver implements DriverSource {
-
- public WebDriver newDriver() {
- EnvironmentVariables environmentVariables = SystemEnvironmentVariables.createEnvironmentVariables();
-
- String username = System.getenv("LT_USERNAME");
- if (username == null) {
- username = (String) environmentVariables.getProperty("lt.user");
- }
-
- String accessKey = System.getenv("LT_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) environmentVariables.getProperty("lt.key");
- }
-
- String environment = System.getProperty("environment");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
- capabilities.setCapability("plugin","Serenity LambdaTest Plugin");
-
- Iterator it = environmentVariables.getKeys().iterator();
- while (it.hasNext()) {
- String key = (String) it.next();
-
- if (key.equals("lt.user") || key.equals("lt.key") || key.equals("lt.grid")) {
- continue;
- } else if (key.startsWith("lt_")) {
- capabilities.setCapability(key.replace("lt_", ""), environmentVariables.getProperty(key));
-
- } else if (environment != null && key.startsWith("environment." + environment)) {
-
- capabilities.setCapability(key.replace("environment." + environment + ".", ""),
- environmentVariables.getProperty(key));
- }
- }
-
- try {
- String url = "https://" + username + ":" + accessKey + "@" + environmentVariables.getProperty("lt.grid")
- + "/wd/hub";
- return new RemoteWebDriver(new URL(url), capabilities);
- } catch (Exception e) {
- System.out.println(e);
- return null;
- }
- }
-
- public boolean takesScreenshots() {
- return false;
- }
-}
diff --git a/src/test/java/com/lambdatest/LambdaTestSerenityTest.java b/src/test/java/com/lambdatest/LambdaTestSerenityTest.java
deleted file mode 100644
index e1d4b36..0000000
--- a/src/test/java/com/lambdatest/LambdaTestSerenityTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.lambdatest;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class LambdaTestSerenityTest {
-
- @BeforeClass
- public static void setUp() throws Exception {
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/lambdatest/cucumber/ParallelChromeTest.java b/src/test/java/com/lambdatest/cucumber/ParallelChromeTest.java
deleted file mode 100644
index b01d49e..0000000
--- a/src/test/java/com/lambdatest/cucumber/ParallelChromeTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.lambdatest.cucumber;
-
-import com.lambdatest.LambdaTestSerenityTest;
-import cucumber.api.CucumberOptions;
-import net.serenitybdd.cucumber.CucumberWithSerenity;
-import org.junit.runner.RunWith;
-
-@RunWith(CucumberWithSerenity.class)
-@CucumberOptions(features = "src/test/resources/features/single.feature")
-public class ParallelChromeTest extends LambdaTestSerenityTest {
-}
diff --git a/src/test/java/com/lambdatest/cucumber/ParallelFirefoxTest.java b/src/test/java/com/lambdatest/cucumber/ParallelFirefoxTest.java
deleted file mode 100644
index 92ae9d8..0000000
--- a/src/test/java/com/lambdatest/cucumber/ParallelFirefoxTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.lambdatest.cucumber;
-
-import com.lambdatest.LambdaTestSerenityTest;
-import cucumber.api.CucumberOptions;
-import net.serenitybdd.cucumber.CucumberWithSerenity;
-import org.junit.runner.RunWith;
-
-@RunWith(CucumberWithSerenity.class)
-@CucumberOptions(features = "src/test/resources/features/single.feature")
-public class ParallelFirefoxTest extends LambdaTestSerenityTest {
-}
diff --git a/src/test/java/com/lambdatest/cucumber/ParallelIETest.java b/src/test/java/com/lambdatest/cucumber/ParallelIETest.java
deleted file mode 100644
index dcef87a..0000000
--- a/src/test/java/com/lambdatest/cucumber/ParallelIETest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.lambdatest.cucumber;
-
-import com.lambdatest.LambdaTestSerenityTest;
-import cucumber.api.CucumberOptions;
-import net.serenitybdd.cucumber.CucumberWithSerenity;
-import org.junit.runner.RunWith;
-
-@RunWith(CucumberWithSerenity.class)
-@CucumberOptions(features = "src/test/resources/features/single.feature")
-public class ParallelIETest extends LambdaTestSerenityTest {
-}
diff --git a/src/test/java/com/lambdatest/cucumber/ParallelSafariTest.java b/src/test/java/com/lambdatest/cucumber/ParallelSafariTest.java
deleted file mode 100644
index 3467ea1..0000000
--- a/src/test/java/com/lambdatest/cucumber/ParallelSafariTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.lambdatest.cucumber;
-
-import com.lambdatest.LambdaTestSerenityTest;
-import cucumber.api.CucumberOptions;
-import net.serenitybdd.cucumber.CucumberWithSerenity;
-import org.junit.runner.RunWith;
-
-@RunWith(CucumberWithSerenity.class)
-@CucumberOptions(features = "src/test/resources/features/single.feature")
-public class ParallelSafariTest extends LambdaTestSerenityTest {
-}
diff --git a/src/test/java/com/lambdatest/cucumber/SingleTest.java b/src/test/java/com/lambdatest/cucumber/SingleTest.java
index 438abd4..07f34cd 100644
--- a/src/test/java/com/lambdatest/cucumber/SingleTest.java
+++ b/src/test/java/com/lambdatest/cucumber/SingleTest.java
@@ -1,11 +1,10 @@
package com.lambdatest.cucumber;
-import com.lambdatest.LambdaTestSerenityTest;
-import cucumber.api.CucumberOptions;
+import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
@RunWith(CucumberWithSerenity.class)
-@CucumberOptions(features = "src/test/resources/features/single.feature")
-public class SingleTest extends LambdaTestSerenityTest {
+@CucumberOptions(features = "src/test/resources/features/a_simple_todo_app.feature")
+public class SingleTest {
}
diff --git a/src/test/java/com/lambdatest/cucumber/pages/TodoApp.java b/src/test/java/com/lambdatest/cucumber/pages/TodoApp.java
index bc54af9..2a83fb7 100644
--- a/src/test/java/com/lambdatest/cucumber/pages/TodoApp.java
+++ b/src/test/java/com/lambdatest/cucumber/pages/TodoApp.java
@@ -1,38 +1,26 @@
package com.lambdatest.cucumber.pages;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.openqa.selenium.support.FindBy;
-
-import net.serenitybdd.core.pages.WebElementFacade;
import net.thucydides.core.annotations.DefaultUrl;
import net.thucydides.core.pages.PageObject;
+import org.openqa.selenium.By;
+
+import java.util.List;
@DefaultUrl("https://lambdatest.github.io/sample-todo-app/")
public class TodoApp extends PageObject {
- @FindBy(name = "li1")
- WebElementFacade element1;
- @FindBy(name = "li2")
- WebElementFacade element2;
- @FindBy(id = "sampletodotext")
- WebElementFacade inputBox;
- @FindBy(id = "addbutton")
- WebElementFacade addButton;
- @FindBy(xpath = "/html/body/div/div/div/ul/li[6]/span")
- WebElementFacade newElement;
- public void clickOn() {
- element1.click();
- element2.click();
+ private final static By LIST_ITEMS = By.cssSelector("div[ng-app='sampleApp'] li");
+
+ public void addNewElement(String newItem) {
+ $("#sampletodotext").sendKeys(newItem);
+ $("#addbutton").click();
}
- public void addNewElement(String newElem) {
- inputBox.sendKeys(newElem);
- addButton.click();
+ public List listItems() {
+ return findAll(LIST_ITEMS).texts();
}
- public void assertEqual(String newString) {
- String text = newElement.getText();
- assertThat(newString).isEqualTo(text);
+ public int itemCount() {
+ return listItems().size();
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/lambdatest/cucumber/steps/TodoAppSteps.java b/src/test/java/com/lambdatest/cucumber/steps/TodoAppSteps.java
index afe91a7..cbc3af4 100644
--- a/src/test/java/com/lambdatest/cucumber/steps/TodoAppSteps.java
+++ b/src/test/java/com/lambdatest/cucumber/steps/TodoAppSteps.java
@@ -1,27 +1,28 @@
package com.lambdatest.cucumber.steps;
import com.lambdatest.cucumber.pages.TodoApp;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
-import cucumber.api.java.en.And;
-import cucumber.api.java.en.Then;
-import cucumber.api.java.en.When;
+import static org.assertj.core.api.Assertions.assertThat;
public class TodoAppSteps {
TodoApp todo;
- @When("^I click on checkboxes$")
- public void search_google_for() throws Throwable {
+ @Given("I have opened the app")
+ @When("I open the app")
+ public void iOpenTheApp() {
todo.open();
- todo.clickOn();
}
- @And("^I add new Element \"([^\"]*)\"$")
- public void thenSubmit(String newText) throws Throwable {
- todo.addNewElement(newText);
+ @When("I add new item {string}")
+ public void iAddNewItem(String item) {
+ todo.addNewElement(item);
}
- @Then("^I Compare the new added element text with \"([^\"]*)\"$")
- public void matchTitle(String matchElem) throws Throwable {
- todo.assertEqual(matchElem);
+ @Then("I should see {int} items")
+ public void iShouldSeeItems(int expectedItems) {
+ assertThat(todo.itemCount()).isEqualTo(expectedItems);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/lambdatest/extensions/LambdaTestScenario.java b/src/test/java/com/lambdatest/extensions/LambdaTestScenario.java
deleted file mode 100644
index 93b39bd..0000000
--- a/src/test/java/com/lambdatest/extensions/LambdaTestScenario.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.lambdatest.extensions;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.client.methods.HttpPatch;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import net.serenitybdd.core.webdriver.RemoteDriver;
-import net.serenitybdd.core.webdriver.enhancers.AfterAWebdriverScenario;
-import net.serenitybdd.core.webdriver.enhancers.BeforeAWebdriverScenario;
-import net.thucydides.core.model.TestOutcome;
-import net.thucydides.core.util.EnvironmentVariables;
-import net.thucydides.core.webdriver.SupportedWebDriver;
-
-public class LambdaTestScenario implements AfterAWebdriverScenario, BeforeAWebdriverScenario {
-
- @Override
- public void apply(EnvironmentVariables environmentVariables, TestOutcome testOutcome, WebDriver driver) {
-
- if ((driver == null) || (!RemoteDriver.isARemoteDriver(driver))) {
- return;
- }
-
- try {
- String sessionId = RemoteDriver.of(driver).getSessionId().toString();
-
- String username = System.getenv("LT_USERNAME");
- if (username == null) {
- username = (String) environmentVariables.getProperty("lt.user");
- }
-
- String accessKey = System.getenv("LT_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) environmentVariables.getProperty("lt.key");
- }
-
- String environment = System.getProperty("environment");
-
- URI uri = new URI("https://" + username + ":" + accessKey
- + "@api.lambdatest.com/automation/api/v1/sessions/" + sessionId);
- HttpPatch putRequest = new HttpPatch(uri);
-
- String result = "completed";
- if (testOutcome.isSuccess()) {
- result = "passed";
- } else if (testOutcome.isFailure() || testOutcome.isError() || testOutcome.isCompromised()) {
- result = "failed";
- }
-
- StringEntity entity;
-
- if (environment != null && environmentVariables.getKeys().contains(".name")) {
-
- entity = new StringEntity("{\"status_ind\":" + "\"" + result + "\"}");
- } else {
-
- entity = new StringEntity("{\"name\":\"" + testOutcome.getStoryTitle() + " - " + testOutcome.getTitle()
- + "\",\"status_ind\":" + "\"" + result + "\"}");
- }
-
- putRequest.setEntity(entity);
-
- HttpClientBuilder.create().build().execute(putRequest);
-
- } catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public DesiredCapabilities apply(EnvironmentVariables environmentVariables, SupportedWebDriver driver,
- TestOutcome testOutcome, DesiredCapabilities capabilities) {
-
- capabilities.setCapability("name", testOutcome.getStoryTitle() + " - " + testOutcome.getTitle());
- return capabilities;
-
- }
-}
\ No newline at end of file
diff --git a/src/test/resources/features/a_simple_todo_app.feature b/src/test/resources/features/a_simple_todo_app.feature
new file mode 100644
index 0000000..bb936b9
--- /dev/null
+++ b/src/test/resources/features/a_simple_todo_app.feature
@@ -0,0 +1,12 @@
+Feature: A Simple Todo App
+
+ Rule: The app should initally contain 5 items
+ Scenario: Can see the default items
+ When I open the app
+ Then I should see 5 items
+
+ Rule: Users can add more items to the list
+ Scenario: Can add new items
+ Given I have opened the app
+ When I add new item "Complete LambdaTest Tutorial"
+ Then I should see 6 items
diff --git a/src/test/resources/features/single.feature b/src/test/resources/features/single.feature
deleted file mode 100644
index ec2cf16..0000000
--- a/src/test/resources/features/single.feature
+++ /dev/null
@@ -1,7 +0,0 @@
-Feature: Google's Search Functionality
-
- Scenario: Can find search results
- When I click on checkboxes
- And I add new Element "Complete LambdaTest Tutorial"
- Then I Compare the new added element text with "Complete LambdaTest Tutorial"
-
diff --git a/src/test/resources/serenity.conf b/src/test/resources/serenity.conf
new file mode 100644
index 0000000..eabe266
--- /dev/null
+++ b/src/test/resources/serenity.conf
@@ -0,0 +1,19 @@
+serenity {
+ take.screenshots = FOR_FAILURES
+}
+
+headless.mode = true
+webdriver {
+ driver = remote
+ remote.url = "https://"${LT_USERNAME}":"${LT_ACCESS_KEY}"@hub.lambdatest.com/wd/hub"
+ capabilities {
+ browserName = "chrome"
+ "goog:chromeOptions" {
+ args = ["remote-allow-origins=*","test-type", "no-sandbox", "ignore-certificate-errors", "--window-size=1000,800",
+ "incognito", "disable-infobars", "disable-gpu", "disable-default-apps", "disable-popup-blocking"]
+ }
+ "LT:options" {
+ platformName = "Windows 10"
+ }
+ }
+}