I'm trying to write some automated tests for this site https://www.jigsaw-online.com/basket/viewbasket
I'm trying to write a test to add or remove qty from a specific item added to the basket page.
I'm having trouble writing xpath that will get me the element for a button where the link contains some value in the href.
Take the add qty button for example this will be get me all the buttons on page
//button//i[@class='fa fa-plus']
This will get me all the items in the basket__items class where the link contains the product I am wanting to add qty to
//ul[@class='basket__items']//a[contains(@href,'12')]
I'm just having trouble combining these two pieces of xpath to get me the add qty button for the product I want to add too.
Can someone help me with this?
This is one possible way to combine the two XPath expressions (formatted for readability) :
Explanation :
//li[contains(@class,'basket__row')]
, expression that select individual basket item row.and .//a[contains(@href,'12')]
in predicate narrow down the result to specific basket item row that you're interested in.//button//i[@class='fa fa-plus']
, which will return the button from the selected basket item row