Framework Features:
- Supports Parallel testing on Selenium Grid and on local execution
- Supports SauceLabs, Browser Stack, Testing Bot
To run the tests on SauceLabs, simply set the saucelabs/browser stack url to the "test.grid.url" property in "src/main/resources/application.properties" file
- Browser Stack: test.grid.url = http://username:[email protected]/wd/hub
- Selenium Grid: test.grid.url = http://selenium-grid-server:4444/wd/hub
- Supports reporting with the help of serenityrunner plugin
- Can write less and do more
- Can integrate any CI tools (Jenkins, Bamboo, Teamcity, Travis, etc.,)
Requirements:
- Maven version 3
- Java version 8
- Cucumber Java plugin for the IntelliJ IDEA
How to write a test:
- To create a new test/scenario, simply add a new feature if the scenario belongs to new feature or add the scenario in the existing feature files if the scenario belongs to the existing feature.
- Scenario/Feature must be written under src/test/resource
- Add the step definitions for the corresponding scenarios in src/test/java
- Add pages, step class in src/main/java/pages and src/main/java/steps respectively
- It is not mandatory to write the step classes under src/main/java/steps and use them in the step definition classes. Instead can directly use the page classes/page objects in the step definition classes Example:
path: src/test/resources/features
@test
Scenario: Validate the search results are displayed
Given I launch the amazon application
Then I search the "laptop" in the search box
And I click the first search result
Then I display the price of the first laptop
path: src/test/java/com/app/tests
public class SearchResultsStepDef {
@Inject
SearchSteps searchSteps;
@Inject
ApplicationSteps appSteps;
@Given("^I launch the amazon application$")
public void iLaunchTheAmazonApplication() throws Throwable {
appSteps.goToHomePage();
}
@Then("^I search the \"([^\"]*)\" in the search box$")
public void iSearchTheInTheSearchBox(String searchTerm) throws Throwable {
searchSteps.searchAnItem(searchTerm);
}
@And("^I click the first search result$")
public void iClickTheFirstSearchResult() throws Throwable {
searchSteps.clickSearchItemByIndex(0);
}
@Then("^I display the price of the first laptop$")
public void iDisplayThePriceOfTheFirstLaptop() throws Throwable {
}
}
Instructions: Run the tests from the command line
- Run the following command to execute the tests
_mvn clean verify_
- To apply the desired capabilities to the remote webdriver, prefix the desired capabilities key with "driver.remote.capability" in the properties Example: driver.remote.capability.browserName=chrome driver.remote.capability.javascriptEnabled=true
- Write Scenarios in src/test/resources/features folder
- Write Step definitions in src/test/java folder
- Reports are generated in target/cucumber-html-reports folder
Run the tests from the Intellij IDEA
- To run the tests from the Intellij IDEA, click on "Run" and then "Edit Configurations"
- Select "Cucumber Java" in the default section of the left side page
- Set -Dguice.injector-source=com.app.configuration.GuiceModule in the VM options and save the configurations
- Choose any scenario you want to run and click the "Run " in the context menu