cancel
Showing results for 
Search instead for 
Did you mean: 

Same xpath value for filters on different web pages, cannot spy correctly

a026833
Level 4

I have to export data from one section of a page and then do the same in another section after scrolling down using Chrome. When I "inspect" each filter in Chrome it giving me the same Xpath expression. The Xpath expression only appears once in Chrome dev tools when I do a find on it see below). How do I get my automation to recognize that I want the filter on the second page??  My automation scrolls to the next page but it continues to use the dropdown from the first page. I have been working on this for a while and getting nowhere. Confluence is the product, which uses Java

a026833_0-1740770575900.png

 

a026833_2-1740770759026.png

a026833_3-1740771291909.png

 

 

3 REPLIES 3

@a026833  Hi,

2 solutions can be considered:
the first one:
- try to put (//your_xpath_expression)[last()] exemple (//button[@id='h'])[last()]

By doing this, your xpath will take your last element.


Second  :  try to see in the inspector in the DOM (the html tree) if the page 2 and 1 have a unique attribute that show us the page number, for example:
div page=1 and inside this div, in the descendant children, we find your element, so your xpath will be for example:
//div[@page=1]//your_xpath_expression it will be on page 1

//div[@page=2]//your_xpath_expression it will be on page 2

try it and let me know.

Dont hesitate to ask question if i am not clear

a026833
Level 4

Thank you so so much! Your first solution did the trick, I was about to give up on this 

@a026833 

Please mark be as best answer if i answer your request that's will help the community