Selenium IDE command for executing a javascript function?

1,529 views
Skip to first unread message

Benedict Angelo P. Mendoza

unread,
Jul 10, 2007, 5:44:37 AM7/10/07
to selenium-users...@googlegroups.com
Selenium IDE command for executing a function? Does anyone know at least one?

coz' im planning to do this...

{code:html}<tr>
<td>{code}+*The Command Here*+{code:html}</td>
<td>javascript:{ a = this.browserbot.getCurrentWindow(); a.parent.myFunction.execThis(); }</td>
<td></td>
</tr>{code}

Need help here... plx.. thnx!! :)

Benedict Angelo P. Mendoza

unread,
Jul 10, 2007, 7:23:19 AM7/10/07
to selenium-users...@googlegroups.com
uhmm... i've already tried that but it gave me this error

*threw an exception: undefined*

thnx for the help... :)

im executing my function from a parent window...

and the function is something like this

function execThis(){
iframe = document.getElementById('iframeID');
searchVal = iframe.document.getElementById('txtSearch').value;
this.anotherFunction("myURLforAJAX?searchVal="+searchVal);
}

from the function on the parentWindow, it goes to an Iframe where the value of my textbox is located
then so on....

i dun have an Idea why the error comes up...

Benedict Angelo P. Mendoza

unread,
Jul 10, 2007, 10:53:24 PM7/10/07
to selenium-users...@googlegroups.com
yeah... when I try to point to the parent window it points to the selenium object... that's why I tried to do this

*javascript:{ a = this.browserbot.getCurrentWindow(); a.parent.myFunction.execThis(); }*

*this.browserbot.getCurrentWindow();* gives me the current window selected or the current object that is selected which is the *iframe* and then
i've done this part....

*a.parent.myFunction.execThis();*

*a* is *equal* to the current selected window or frame which is my *iframe* then

I've done *a.parent* to get the parent window.... coz the function i'm trying to execute is located there... but still it gives me

*Threw an Exception: undefined*

I think i've done what is stated in what you've just mentioned...

I'm sorry if i've caused to much trouble on your part :(

Rajendra Singh

unread,
Jul 11, 2007, 1:17:55 PM7/11/07
to selenium-users...@googlegroups.com
What does the function do? If it does anything on the new page then you may need to rescope, eg instead of
a.parent.myFunction.execThis();
use
with (a.parent) {myFunction.execThis();}

-raj

Benedict Angelo P. Mendoza

unread,
Jul 12, 2007, 3:11:55 AM7/12/07
to selenium-users...@googlegroups.com
*reply to raj:*
uhmm.. raj that expression would result to "missing ; before statement"... :)

*reply to konstantin:*
i think i've already tried that... :(
but instead of echo i've used console.log, coz' im also using the firebug firefox extension..
and as a result

*this.browserbot.getCurrentWindow();* points to my iframe...

but still, the error "Threw an exeption: undefined" is still there...

Reply all
Reply to author
Forward
0 new messages