Created
August 6, 2014 18:44
-
-
Save RobertFischer/af21ce4b4b88a480f470 to your computer and use it in GitHub Desktop.
Geb Boilerplate Script
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
// The first time you run this, it will take a very long, annoyingly silent pause while it loads libraries | |
@Grapes([ | |
@Grab("org.gebish:geb-core:0.9.3"), | |
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.41.0"), | |
@Grab("org.seleniumhq.selenium:selenium-support:2.41.0") | |
]) | |
import geb.Browser | |
Browser.drive { | |
/* Put your Geb code here. For instance... | |
System.out.println("Going to Google"); | |
go "http://google.com/ncr" | |
// make sure we actually got to the page | |
assert title == "Google" | |
// enter wikipedia into the search field | |
$("input", name: "q").value("wikipedia") | |
// wait for the change to results page to happen | |
// (google updates the page dynamically without a new request) | |
System.out.println("Waiting for search"); | |
waitFor { title.endsWith("Google Search") } | |
// is the first link to wikipedia? | |
def firstLink = $("li.g", 0).find("a.l") | |
assert firstLink.text() == "Wikipedia" | |
// click the link | |
firstLink.click() | |
// wait for Google's javascript to redirect to Wikipedia | |
System.out.println("Waiting for Wikipedia"); | |
waitFor { title == "Wikipedia" } | |
System.out.println("At Wikipedia"); | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment