how to use javascript commands in selenium ide (document.getElementById)

1,825 views
Skip to first unread message

chec...@abv.bg

unread,
May 13, 2013, 5:57:59 AM5/13/13
to seleniu...@googlegroups.com
I have seen people asking questions
how to do this and that in selenium ide

and people replying with test code that includes javascript commands like

document.getElementById

how can I use this type of commands as well?

David

unread,
May 13, 2013, 12:51:03 PM5/13/13
to seleniu...@googlegroups.com
Why do you want/need to execute javascript from the IDE? I don't know if that's possible, but it is generally better to do that from code with Selenium RC / WebDriver. I believe document.getElementById isn't generally available to Selenium RC either, only in WebDriver.

Tarun Kumar

unread,
May 13, 2013, 11:23:20 PM5/13/13
to seleniu...@googlegroups.com
Copied from Selenium IDE Reference - 

###################################################
storeEval(script, variableName)
Generated from getEval(script)
Arguments:
  • script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.

Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object. Use window to refer to the window of your application, e.g. window.document.getElementById('foo')

If you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("id=foo") where "id=foo" is your locator.

########################################################

chec...@abv.bg

unread,
May 14, 2013, 2:56:06 AM5/14/13
to seleniu...@googlegroups.com
Can you give me a real life example, as I am not good at understanding concepts :)
@David - I do not necessarily need to use it, but yesterday I encountered a problem and I googled it and all the solutions implemented this type of commands
Reply all
Reply to author
Forward
0 new messages