Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xpath OR operator for multiple values

For the following scenario, xpath OR operator is not working. The same label showing in different nodes in different pages.

@FindBy(xpath = "(//label[@class='x-form-item-label'])[19] | (//label[@class='x-form-item-label'])[36]")
public WebElement lblFee;
like image 634
Kaliraj Subramanian Avatar asked May 07 '26 16:05

Kaliraj Subramanian


1 Answers

Use the position() function with the or operator:

@FindBy(xpath = "(//label[@class='x-form-item-label'])[position()=19 or position()=36]")
public WebElement lblFee;
like image 160
Florent B. Avatar answered May 10 '26 18:05

Florent B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!