Javascript evaluation.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Javascript evaluation.

GW-5
I am writing some simple javascript to get the current Date and then use it as input to fields inside my Selenium scripts.

Here is a snippet :

store | javascript{new Date()}             | x
store | javascript{${x}.getDate()}         | y
type  | segmentDetails[0].onwardDay | ${y}

So I want to get the Day of the month into the varialbe y and then use it as an input to the type field.

When I run this, I get the following error --

Selenium failure. Please report to [hidden email], with details from the logs at the base of the page. The error message is: Expected ';'

Thanks in advance for your help!

Regards,
Satish.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1008&messageID=2821#2821

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Javascript evaluation.

Dan Fabulich
Satish Kaushik wrote:

> I am writing some simple javascript to get the current Date and then use it as input to fields inside my Selenium scripts.
>
> Here is a snippet :
>
> store | javascript{new Date()}             | x
> store | javascript{${x}.getDate()}         | y
> type  | segmentDetails[0].onwardDay | ${y}
>
> So I want to get the Day of the month into the varialbe y and then use it as an input to the type field.
>
> When I run this, I get the following error --
>
> Selenium failure. Please report to [hidden email], with details from the logs at the base of the page. The error message is: Expected ';'
>
> Thanks in advance for your help!

I don't think it's allowed to use braces-within-braces like you're doing
in line 2 above.  Instead, everything inside the first set of braces is
being interpreted as javascript.  "${x}.getDate()" is invalid javascript,
which is what the browser is telling you.

Instead, maybe try javascript{storedVars["x"].getDate()}, or, for that
matter, just javascript{(new Date()).getDate()} in one line.

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Javascript evaluation.

GW-5
Thanks Dan.

Making the Script simpler according to your suggestion made it work.

Thanks again,
Satish.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1008&messageID=2824#2824

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...