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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -