Quality Testing

Quality is delighting customers

Can any one provide one example selenium script which has been used Java script for getting Dynamic values

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

Views: 170

Reply to This

Replies to This Discussion

Hi Sri,

 

Please go through my blog..you can see some useful tutotial there..

 

http://testerinyou.blogspot.com/

 

Thanks,

Naga

Hi Nagara

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>

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

I have worked out with this script!

Now onwards I too love this script... Thanks a ton!

np :D

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

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.

 

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.

Are you using firebug ? Firebug is a very powerfull tool. Use it and send my how exactly does this element look like ?

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 :)

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.

RSS

TTWT Magazine

Webinar

You Can


Call for Articles

Advertisement

Videos

  • Add Videos
  • View All

Badge

Loading…

© 2012   Created by Quality Testing.

Badges  |  Report an Issue  |  Terms of Service