PhantomjsDriver Geb with Jquery click events throwing error workaround

When moving to phantomjs from using Geb with a browser you will find that some click events do not fire and give you an error.  I have not investigated this thoroughly on what works and what fails.

Tested Config:
Geb: 0.6.3
Phantomjs: 1.9.1
Jquery: 1.7.1
phantomjsdriver: 1.0.4

The problem I had was   $(“.SUBMIT_BUTTON”).click() will not always work and give you the following error:

Error: cannot access member `resetOneShotCallbacks’ of deleted QObject

:/ghostdriver/session.js:197
:/ghostdriver/session.js:227

My workaround was to fire a query selector event.

js.exec(“document.querySelector(‘.SUBMIT_BUTTON’).click();”)

Little convenience method to put in your Geb helper class

void clickElement(name){
   js.exec("document.querySelector('$name').click();")
}

In you Geb test case

    clickElement(".SUBMIT_BUTTON")
    //submitButton.click()  // the old action that no longer works.

You will have to go through your whole suite of tests several times to find out which events you will have to change.  Button clicks may not be the only thing that fails.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s