Forked from andidev/WebDriverExtensionsExampleTest.java
Created
September 3, 2017 11:32
-
-
Save swapnilshrikhande/8189cc4c1be017891193bb3928105253 to your computer and use it in GitHub Desktop.
Example of a WebDriver Extensions Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.companyname</groupId> | |
<artifactId>projectname</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
<dependencies> | |
<dependency> | |
<groupId>com.github.webdriverextensions</groupId> | |
<artifactId>webdriverextensions</artifactId> | |
<version>3.3.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>com.github.webdriverextensions</groupId> | |
<artifactId>webdriverextensions-maven-plugin</artifactId> | |
<version>3.1.1</version> | |
<executions> | |
<execution> | |
<goals> | |
<goal>install-drivers</goal> | |
</goals> | |
</execution> | |
</executions> | |
<configuration> | |
<drivers> | |
<driver> | |
<name>internetexplorerdriver</name> | |
<version>3.2.0</version> | |
</driver> | |
<driver> | |
<name>chromedriver</name> | |
<version>2.27</version> | |
</driver> | |
<driver> | |
<name>geckodriver</name> | |
<version>0.14.0</version> | |
</driver> | |
</drivers> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.openqa.selenium.support.FindBy; | |
import org.openqa.selenium.WebElement; | |
import com.github.webdriverextensions.junitrunner.WebDriverRunner; | |
import com.github.webdriverextensions.junitrunner.annotations.*; | |
import static com.github.webdriverextensions.Bot.*; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
@RunWith(WebDriverRunner.class) | |
@Firefox | |
@Chrome | |
@InternetExplorer | |
public class WebDriverExtensionsExampleTest { | |
@FindBy(name = "q") | |
WebElement queryInput; | |
@FindBy(name = "btnG") | |
WebElement searchButton; | |
@FindBy(id = "search") | |
WebElement searchResult; | |
@Test | |
public void searchGoogleForHelloWorldTest() { | |
open("http://www.google.com"); | |
assertCurrentUrlContains("google"); | |
type("Hello World", queryInput); | |
click(searchButton); | |
waitFor(3, SECONDS); | |
assertTextContains("Hello World", searchResult); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment