Get element property with JQuery selector and Selenium IDE 2.0.0

我的未来我决定 提交于 2019-12-06 22:14:27

assertEval is what you're looking for. First though, you'll have to store a reference to the jquery using a store command earlier on.

Here is an example:

<tr>
    <td>store</td>
    <td>this.browserbot.getUserWindow().jQuery</td>
    <td>jq</td>
</tr>
<tr>
    <td>assertEval</td>
    <td>${jq}('.response-options.selected').prop('id')</td>
    <td>**the name of the ID you want to match against**</td>
</tr>

Just in case it helps others, I wanted to just run javascript (including jquery statements in my page) and the accepted answer (1000s kudos to you Scottingham !) is the starting point. You just have to redefine $ sign with jQuery from getUserWindow !

Then add a runScript command, with in the target the following :

javascript{var $=this.browserbot.getUserWindow().jQuery; ... your javascript there}

For example

javascript{var $=this.browserbot.getUserWindow().jQuery; $('#myid').click();}

and remember that selenium only sees what is ctually visible on the page... and so do your jquery selectors in that context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!