OiO.lk Blog CSS how to make a selector by xpath
CSS

how to make a selector by xpath


I have some data stored in the generatedName constant, and I need to locate a nearby HTML element (the options button) for my test so I can click it. However, my current approach doesn’t seem to work:

javascript

const rowElement2 = await browser.$(`//tr[td//text()[contains(., '${generatedName}')]]`);
await rowElement2.waitForDisplayed();
const buttonElement2 = await rowElement2.$('title="Options"'); 
await buttonElement2.waitForDisplayed();
await buttonElement2.click();

I was advised to use XPath to find the options button, but I’m not sure how to do that. Could anyone help me with an XPath solution for this? Thanks!



You need to sign in to view this answers

Exit mobile version