How to store "first child" in a variable called str then use, Selenium Notes, Examples, Videos By.www.laxmiroy.blogspot.com/
String str = selenium.getText("css=div#combinatorTest > span");
If you need to store the text of immediate element <a>second child</a> in a variable called str then use
String str = selenium.getText("css=div#combinatorTest > span>a");
If you element has many value in its class then you can identify the element or you can store the element text in a variable
<a class="class1 class2 class3">this is the element</a>
You can use below code for verifying the element or storing the text in the element.
Verifying element in RC
verifyTrue(selenium.isElementPresent("css=a[class~=\"class2\"]"));
Verifying element in IDE
<tr>
<td>verifyElementPresent</td>
<td>css=a[class~="class2"]</td>
<td></td>
</tr>
storing element text in a variable using RC
String str = selenium.getText("css=a[class~=\"class3\"]");
storing element text in a variable using IDE
<tr>
<td>storeText</td>
<td>css=a[class~="class3"]</td>
<td>str</td>
</tr>
Testing preceding combinator elements
<div id="combinatorTest">this is the parent element. <span id="firstChild">this is a child element <a>and grandson element</a></span>, <span>another child element</span>, <span>last child element<span></span></span></div>
No comments:
Post a Comment