Thursday, November 3, 2011

How to identify element using more than one css attributes.

How to identify element using more than one css attributes.Selenium Notes, Examples, Videos By.www.laxmiroy.blogspot.com/


Lets say your element is in this format.

<a alt="foo" class="a2" href="#id2" name="name1" id="id2">this is the <b>second</b> <span selenium:foo="bar">element</span></a>

then if you want to store "this is the second element" in a variable called str the

Selenium IDE

<tr>
<td>storeText</td>
<td>css=a[name*="name"][alt="foo"]</td>
<td>str</td>
</tr>

Selenium RC

String str = selenium.getText("css=a[name*=\"name\"][alt=\"foo\"]");

If you want to store only "element" from above element then use below code
Selenium IDE

<tr>
<td>storeText</td>
<td>css=a[name*="name"][alt="foo"]>span</td>
<td>str</td>
</tr>

Selenium RC

String str = selenium.getText("css=a[name*=\"name\"][alt=\"foo\"]>span");

No comments:

Post a Comment