Conditional XPATH in Selenium WebDriver ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional XPATH in Selenium WebDriver ?

Robin Tyagi
Hi Folks,

Can someone suggest me how shall we write XPATH for below Tags.

Lets consider, there is 1 Div and 3 Span tag. Here we have to write XPATH for only 1 Span which will contain . Position of  is getting changed dynamically.  could be found with in 1, 2 OR 3 Span Tag. So wherever it occurs, write XPATH only for that valid span having

<Div class='country'>
 US
 Germany
 
 India    Note :  could be at any position, at 1st span, 2nd or 3rd
</Div>

Thanks,
Robin
Reply | Threaded
Open this post in threaded view
|

Re: Conditional XPATH in Selenium WebDriver ?

Robin Tyagi
I am trying to give more explanation. please have a look. will //div/span/a work ? or what should be the right xpath

1. <div>
.......................
.......................
 ..........  Here  occurs at 3rd span
</div>

2. <div>
 
..........
.......................
......................  Here  occurs at 1st span
</div>

3. <div>
......................
 
..........
......................  Here  occurs at 2nd span
</div>

Note -> position of
 is dynamic, it may occur in any of the three span tag
Reply | Threaded
Open this post in threaded view
|

Re: Conditional XPATH in Selenium WebDriver ?

softwaretestingforum
Administrator
In reply to this post by Robin Tyagi
You mentioned in first post -

which will contain . 

but I don't see . in html example. Could you post html of example after hiding any sensitive information?
~ seleniumtests.com