| || |
Finding elements in nested <div> using Selenium in C#
I have to parse a page that has a very deep <div> nesting structure. There are no "ids" for the elements that i have to locate. The following is a structure example:
I want to do the following using Selenium in C#:
1. Locate Col2.
2. Then find a specific record in it.
3. Based on that specific record, i want to move to the Col4
4. In Col4, i want to perform an action on the element.
Now what would be the best strategy to do this? Let me know if more info is required to understand this.
Help much appreciated!
have you tried using xpath ?
like the previous guy said, probably xpath works best for that type of find since you can traverse both up and down the tree.
//div[@class='Col2' and contains(.,'your matching text')]/../div[@class='Col4']/some sub element
Note the '../' which allows you to pop up to the parent element, then the following slash to pop down to the next matching child.
Last edited by dlai; 04-11-2015 at 07:28 PM.
Tags for this Thread