Forum Discussion

gmparker2000's avatar
gmparker2000
New Contributor
12 years ago

Geb Script JQuery

Firstly, let me apologize if this post gets added twice. I tried to post last night but the post seems to have disappeared. Not sure if this means that it's in the hands of the forum moderator waiting approval, but in any case it seems lost and does not show up under my posts.

The site I am testing redirects to a login screen, then back to the site where the main page is initialized in the JQuery ready event. In the ready event the page loads some JavaScript asynchronously by injecting a script tag into the DOM. The script I wrote to test this successfully logs in and gets to the main page; however, the injected JavaScript, which retrieves JSON to build much of the content, does not seem to get loaded. Any help would be appreciated. Here is the script:

@Grab(group='org.codehaus.geb', module='geb-core', version='latest.release')
@Grab(group='org.seleniumhq.selenium', module='selenium-htmlunit-driver', version='latest.release')

import geb.Browser
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

Browser.drive() {

go "http:/mysite";

$("input[name=username]").value("myusername");
$("input[name=password]").value("mypassword");
$("#loginButton").click();

waitFor() {
$("#header").text() == 'Main Site Heading'
}

// I tried waiting indefinitely, for a class I'm expecting, etc. This always times out.
waitFor() {
$(".someDynamicallyCreatedClass").present
}

...
}
No RepliesBe the first to reply