Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save swapnilshrikhande/1ce1a40c1a8a9726590c905dded6cfa7 to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/1ce1a40c1a8a9726590c905dded6cfa7 to your computer and use it in GitHub Desktop.
Example of a WebDriver Extensions Test written in Groovy
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