Quality is delighting customers
Greetings,
Can Any one help me by sending one example selenium script which has been used Java script for getting Dynamic values.
My requirement is I want to create a test suite for registration process having username a primary key.
I have recorded a test with some XYZ user name, but while running the same script system is not accepting this script because the user name is primary key(Unique)
So any one provide some example test suite to get the user name value dynamically?
I will be very thankful to you people
Best regards
-Sri
Tags:
Permalink Reply by Nagraju dasam on December 13, 2010 at 12:18pm Hi Sri,
Please go through my blog..you can see some useful tutotial there..
http://testerinyou.blogspot.com/
Thanks,
Naga
Permalink Reply by Sri Balaji Bandaru on December 13, 2010 at 1:26pm Hi Nagara
Permalink Reply by Master Blaster on December 13, 2010 at 2:05pm Hi,
this one is using selenese and time function. I like it because it also gives you time of script, I am using store value from script (storeeval). Next time you operate with Name variable you will get dynamic time.
<tr>
<td>storeEval</td>
<td>new Date().getHours()</td>
<td>hodina</td>
</tr>
<tr>
<td>storeEval</td>
<td>new Date().getMinutes()</td>
<td>minuta</td>
</tr>
<tr>
<td>storeEval</td>
<td>new Date().getDate()</td>
<td>den</td>
</tr>
<tr>
<td>storeEval</td>
<td>new Date().getMonth()</td>
<td>mesic</td>
</tr>
<tr>
<td>store</td>
<td>${mesic}${den}${hodina}${minuta}</td>
<td>cas</td>
</tr>
<tr>
<td>store</td>
<td>XYZ ${cas}</td>
<td>Name</td>
</tr>
Permalink Reply by Sri Balaji Bandaru on December 13, 2010 at 2:21pm Hi,
Thank you so much, This is really great and it might be user full for many test cases..!
Let me try with this..
Can not forget your help...:)
Cheer's
-Sri
Permalink Reply by Sri Balaji Bandaru on December 13, 2010 at 4:45pm I have worked out with this script!
Now onwards I too love this script... Thanks a ton!
Permalink Reply by Master Blaster on December 13, 2010 at 8:46pm np :D
Permalink Reply by Sri Balaji Bandaru on December 15, 2010 at 1:25pm Hi,
Do you have any script like to get or identify the dynamically genrated value by selenium,
My Problem is
I can able to create a task with dynamic name by using your script, Now I want to edit the latest task which is created dynamically.
For this reason I need to make identify the latest created (Dynamical Task) to the selenium
It will be very help full to me if any one helped on this
Best Regards,
Sri
Permalink Reply by Master Blaster on December 15, 2010 at 3:52pm I dont think you need script for that. You just have to use variable from previous script. The values of this dynamically created variable is stil in variable name. you can also store this variable using store funcion into another var.
<tr>
<td>store</td>
<td>${name}</td>
<td>last_name</td>
</tr>
if you are using selenium IDE to orchestrate your script. selenium IDE remember all variables in current test suite and if you want to click on link that has this name you will just write.
<tr>
<td>click</td>
<td>link=${last_name}</td>
<td></td>
</tr>
if you are using selenium RC you will need to create this var as global var.
Permalink Reply by Sri Balaji Bandaru on December 16, 2010 at 10:29am Hello,
I have tried with this it is working for links But not for the text available at inner html..
Iam keep trying this...
And thank you so much for your continuous help...:)
Best regards,
Sri.
Permalink Reply by Master Blaster on December 16, 2010 at 5:05pm Are you using firebug ? Firebug is a very powerfull tool. Use it and send my how exactly does this element look like ?
Permalink Reply by Sri Balaji Bandaru on December 20, 2010 at 3:47pm Hi, Yes I am using firebug as well..
My problem get solved by using the below command
Click css=span:contains('selenium Task ${cas}')
Here (selenium Task ${cas}) is the value generated dynamically
Thanks allot for your help :)
Permalink Reply by Master Blaster on December 21, 2010 at 3:24pm Np. Your locator is going to be quite stable
You can you different aproach using Xpath
//span[contains(text(), "selenium Task ${cas}")]
but you need to remember that the selenium will look for first element with those values. if there will be 2 or more elements with this atribute it will always choose first one. But most of the time it is going to be very stable.
© 2012 Created by Quality Testing.