A playground for the Java BDD Tools and Selenium Webdriver based frameworks.
There are some maven projects using different BDD tools performing the similar UI test.
Test steps:
- Find a user with a nickname mcgray on a using GitHub search
- Proceed to the user profile page
- Search for the bdd-tools repository on the user public repository list
- Proceed to bdd-tools repository
- After that each particular project traverses to the test file and searches for the hidden treasure text inside the test text.
Concordion is a simple BDD tool which uses HTML files which are instrumented with special attributes as test scenarios. To create a test you need to create an HTML story file and a JUnit test (Concordion runner is used) with the same name but with *Test suffix. After the test execution Concordion creates an HTML result file which is your story file with highlighted test execution results. For more details, please see Concordion documentation.
Plain vanilla Webdriver with Page Object pattern is used for the first example project. No step abstraction introduced. The thing worth mentioning here is a custom Predicate to wait until jQuery done with Ajax:
protected void waitForAjax() throws InterruptedException {
new WebDriverWait(getWebDriver(), SHORT_WAIT_IN_MILISEC).until(new Predicate<WebDriver>() {
@Override
public boolean apply(final WebDriver input) {
return (Boolean) ((JavascriptExecutor) input).executeScript(
"return window.jQuery.active == 0");
}
});
}
You can run the test using maven:
mvn clean test
Or using Gradle (no installation needed):
./gradlew clean test
Or using your favorite IDE (in this case you should set the webdriver.chrome.driver
the location of your Chrome Driver and concordion.output.dir
if you want to specify the place where to put test result)
JBehave is well-known and widely used BDD implementation for Java which uses plain text scenario files and map them to Java classes using @Given, @When, @Then annotations.
Thucydides is an acceptance testing framework.
To start with using both frameworks I recommend to create a maven project from thucydides-jbehave archetype. It is updated quite frequently and will save you a lot of time setting up the project.
mvn archetype:generate
- archetype number 191.
To run test using maven:
mvn clean integration-test site
(Only maven build for this project because of the thucydides-maven-plugin)
To run using IDE (in this case Thucydides will not generate results because it uses maven site plugin) - run the StoryRunner
To be continued
Cucumber-JVM is a Cucumber implementation for Java. ( Cucumber is a canonical BDD tool originally designed for Ruby)
Html-Elements is a framework designed by Yandex and built to be used with Webdriver tests.
Both maven and Gradle builds available.
To be continued
Selenide is a Webdriver based UI acceptance testing framework developed by Codeborne.
The current example has no BDD tool yet. There are two examples currently. Both are TestNG tests one with and one without Page Objects.
To be continued