Get element with jquery and selenium IDE 1.0.8 Get element with jquery and selenium IDE 1.0.8 selenium selenium

Get element with jquery and selenium IDE 1.0.8


Based on the other posts I tried the following and it worked.

Add the code below to user-extensions.js:

function jQuery (selector){    return selenium.browserbot.getUserWindow().jQuery(selector);}

You can then access any jQuery function by using the keyword jQuery instead of the $. Just make sure that the page you are testing is referencing the jQuery js file.


To use jQuery with Selenium IDE, it's location is below. (Be sure to have loaded jQuery in your page)

this.page().getCurrentWindow().wrappedJSObject.jQuery()

You can store the function location in a Selenium variable.

<tr>    <td>store</td>    <td>this.page().getCurrentWindow().wrappedJSObject.jQuery</td>    <td>jq</td></tr>

Then you can use them in your Tests like:

<tr>    <td>assertEval</td>    <td>${jq}('div').attr('foo')</td>    <td>bar</td></tr>

Above matches <div foo='bar' /> using jQuery.


Edit: Alternatively you could access it by:

this.browserbot.getUserWindow().jQueryselenium.browserbot.getUserWindow().jQuery

source of alternate: http://cssgreut.wordpress.com/2010/12/20/run-selenium-ide-tests-with-jquery-selectors/


try using jQuery instead of $(). The dollar sign has a different meaning in selenium.

EDIT

As far as I can tell you can't use jQuery to select elements. Google searches turned up nothing. Just use Xpath.