Last active
June 27, 2017 09:55
-
-
Save andidev/b182c59a92d5ad66b035 to your computer and use it in GitHub Desktop.
Example of a WebDriver Extensions Test written in Groovy
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; | |
@Grab(group='com.github.webdriverextensions', module='webdriverextensions', version='3.3.0') | |
@RunWith(WebDriverRunner) | |
@Firefox | |
@Chrome | |
@InternetExplorer | |
class WebDriverExtensionsGroovyExampleTest { | |
@FindBy(name = "q") | |
WebElement queryInput; | |
@FindBy(name = "btnG") | |
WebElement searchButton; | |
@FindBy(id = "search") | |
WebElement searchResult; | |
@Test | |
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
groovy -Dwebdriver.chrome.driver=path/to/chromedriver -Dwebdriver.ie.driver=path/to/iedriver WebDriverExtensionsGroovyTest.groovy
The test preforms a Google search for "Hello World" and then asserts that the search result contains the text "Hello World"