How to select nested elements using standard CSS selectors (nth-of-type or nth-child) for Selenium? -
how select paragraph tag b (or c), using nth-child or nth-of-type? using selenium webdriver.
<tr> <td> <p class="myclass">a</p> </td> </tr> <tr> <td> <p class="myclass">b</p> </td> </tr> <tr> <td> <p class="myclass">c</p> </td> </tr>
background: i'm trying automate testing using selenium webdriver, , since nth(i) works in ide, i'm trying determine how grab element using standard css selectors.
when selecting first element, works, not when selecting nth element. assume due nesting.
not work:
.myclass:nth-of-type(2) (locater not found, according selenium ide)
.myclass:nth-child(2) (locater not found, according selenium ide)
this works selenium webdriver:
string css = ".myclass"; list<webelement> list = driver.findelements(by.cssselector(css)); webelement e = list.get(n);
it's not ideal, works.
Comments
Post a Comment