mardi 26 janvier 2021

XPATH: trying to select button from element where span class contains certain text

I'm trying to select the specific button of a class which also contains a certain text in it's span class. The website is setup to load random elements when visiting, so I can't use more specific paths I think.

Path to button

xpath = "/html/body[@class='js-page-layout-main']//div[@class='main-container']//div[@class='wishlist-selector wishlist-selector--product-listing']//button[@title='Adicionar a lista de desejos']"

Path to span

xpath = "//span[contains(text(),'Poucas unidades')]"

both expressions work for themself, but when I pipe them together the button of another element get's selected and not the button with the desired text in it's span class. I'm not exactly sure why this doesn't work..

EDIT:

piped together

xpath = "//span[contains(text(),'Poucas unidades')] | /html/body[@class='js-page-layout-main']//div[@class='main-container']//div[@class='wishlist-selector wishlist-selector--product-listing']//button[@title='Adicionar a lista de desejos']"



Aucun commentaire:

Enregistrer un commentaire