nxf5025
nxf5025

Reputation: 223

Selenium IDE storeText with elements having the same class

For example, how would you store the text of the following:

<div class="value">ABC</div>
<div class="value">123</div>

In the IDE I would have:

Command ::: Target : : : Value
storeText : : : ????? : : : Key1
storeText : : : ????? : : : Key2

I want to store the ABC as key1 and the 123 as Key2 so how do I make my target point to the correct element. Is there a way to index such as class=value[0] and class=value[1] to do this?

Upvotes: 1

Views: 2096

Answers (3)

Arian Al Lami
Arian Al Lami

Reputation: 937

If you have fire bug add-on of the Firefox installed you can do the following:

  1. Right click on the element and click on inspect element with Firebug and select the div or element that you want,
  2. Right click on it and then click on Copy CSS path
  3. In the your selenium plugin Target type "css=" after that paste the css path
  4. now when you use the echo command next and run the test you should see the result. in the log section

Upvotes: 0

Janesh Kodikara
Janesh Kodikara

Reputation: 1821

Also you could use storeText : : : //div[@class='value'][last()] : : : Key2

Please see following link for details http://zvon.org/xxl/XPathTutorial/General/examples.html

Upvotes: 0

Richard
Richard

Reputation: 9019

You can use xpath for the Target:

Command   : : : Target                   : : : Value
storeText : : : //div[@class='value'][1] : : : Key1
storeText : : : //div[@class='value'][2] : : : Key2

The [n] is an index that will return the nth match.

Upvotes: 1

Related Questions