to identify the element within the element we will use , Selenium Notes, Examples, Videos By.www.laxmiroy.blogspot.com/
css=div#structuralPseudo :nth-child(n)
1. To identify first element in pseudo element id="structuralPseudo and store its text.
String str = selenium.getText("css=div#structuralPseudo :nth-child(n)");
this will store "span1" in str variable.
2. To identify second element in pseudo element id="structuralPseudo and store its text.
String str = selenium.getText("css=div#structuralPseudo :nth-child(2n)");
this will store "span2" in str variable.
3. To identify third element in pseudo element id="structuralPseudo and store its text.
String str = selenium.getText("css=div#structuralPseudo :nth-child(3n)");
this will store "span3" in str variable.
...
...
...
8.. To identify the last element in pseudo element id="structuralPseudo and store its text.
String str = selenium.getText("css=div#structuralPseudo :nth-child(3n)");
this will store "div4" in str variable.
9. But you can access first and last child directly
to access first element
String str = selenium.getText("css=div#structuralPseudo :first-child");
this will store "span1" in str variable
To access last element
String str = selenium.getText("css=div#structuralPseudo :last-child");
this will store "div4" in str variable
For more details about css selector please visit .
http://www.w3.org/TR/CSS2/selector.html
<input type="text" disabled="true" value="disabled" name="disabled">
assertTrue(selenium.isElementPresent("css=input[type=\"text\"]:disabled"));
<input type="checkbox" checked="true" value="checked" name="checked">
assertTrue(selenium.isElementPresent("css=input[type=\"checkbox\"]:checked"));
No comments:
Post a Comment