Can I Execute jQuery Commands using Selenium Library?

685 views
Skip to first unread message

Selber, Heiko (NSN - DE/Berlin)

unread,
Dec 7, 2010, 10:07:12 AM12/7/10
to robotframe...@googlegroups.com
Hello,

I'm testing a web page where I need to check whether objects are visible.

jQuery has a simple method to do that, namely: $(element).is(":visible")

I don't know how to do the same with robot and/or selenium.

Therefore I'd like to be able to execute jQuery commands from robot. Is it possible?

I found that you can define a jQuery based location strategy as described here: http://code.google.com/p/robotframework-seleniumlibrary/wiki/jQueryElementSelectors

But I don't want to locate the objects (I know their IDs), I need to check their visibility.

It would be nice if anybody could give me a hint how to do it.

Thanks,

Heiko

PS: Of course, it doesn't have to be jQuery. I'd appreciate any other way to determine the visibility.

Pekka Klärck

unread,
Dec 7, 2010, 5:02:03 PM12/7/10
to heiko....@nsn.com, robotframe...@googlegroups.com
2010/12/7 Selber, Heiko (NSN - DE/Berlin) <heiko....@nsn.com>:

>
> PS: Of course, it doesn't have to be jQuery. I'd appreciate any other way to determine the visibility.

Have you tested `Element Should (Not) Be Visible` keywords in
SeleniumLibrary 2.5?

http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.5#Element%20Should%20Be%20Visible

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Janne Härkönen

unread,
Dec 8, 2010, 1:06:45 AM12/8/10
to heiko....@nsn.com, robotframe...@googlegroups.com
On Tue, Dec 7, 2010 at 5:07 PM, Selber, Heiko (NSN - DE/Berlin)
<heiko....@nsn.com> wrote:
> Hello,
>
> I'm testing a web page where I need to check whether objects are visible.
>
> jQuery has a simple method to do that, namely: $(element).is(":visible")
>
> I don't know how to do the same with robot and/or selenium.
>
> Therefore I'd like to be able to execute jQuery commands from robot. Is it possible?

You should be able to execute arbitrary jQuery (which after all is
just JavaScript) with Execute Javascript -keyword of SeleniumLibrary.
That keyword just returns the value of the last executed statement.

thanks,
__j

--
Janne Härkönen    | Software Craftsman @ Reaktor
http://reaktor.fi | http://twitter.com/#!/janneharkonen

Selber, Heiko (NSN - DE/Berlin)

unread,
Dec 9, 2010, 12:12:17 PM12/9/10
to ext Pekka Klärck, robotframe...@googlegroups.com
Hi Pekka,

that was too easy :-)

Kiitos for your hint, it works fine.

My bookmark of the selenium library documentation was stuck at 2.4, so I hadn't found it.

Out of curiosity, I also tried to execute the jQuery through Selenium as suggested by Janne, but somehow I didn't manage to do that yet. But I'll keep trying...

Regards,

Heiko

Reply all
Reply to author
Forward
0 new messages