开发者

Using Jquery with Seleninum RC user-extension.js

I want to include Jquery to our current automation project running Selenium RC ( written in java ).

So we can rely on that JS library for writing our java script code extending the current user-extension.js.

I have heard and searched the web and many say it can be done, by include the source in the user extension o even by adding the library to the core selenium-server.jar.

I have tried both approaches with out luck.

All the time I try to reference Jquery in my java script code, I get a Selenium error "jQuery is not defined".

Maybe am calling the jquery func开发者_JS百科tions wrong inside my user-extension.js, I just don't know.

Any help or guidance would be appreciated. bye


I use runScript() and able to attach jQuery to any page in Selenium RC

HERE

The script is not Java, but I believe you can use the same approach.

** Use window.jQuery instead of jQuery in the getEval() call


In Selenese (Selenium IDE), I tried runScript with the 1.6.1 jQuery source, and I got it running, if I escape the source before adding it to the testcase html. Finally, I added doInjectJQuery to my user-extions.js

Selenium.prototype.doInjectJQuery = function() {
/* include JQuery source here; no escaping needed */
}

Now, the following testcase seems to work:

<tr>
<td>injectJQuery</td>
<td></td>
<td></td>
</tr>
<tr>
<td>assertEval</td>
<td>typeof($)</td>
<td>function</td>
</tr>
<tr>
<td>assertEval</td>
<td>typeof(jQuery)</td>
<td>function</td>
</tr>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜