selenium - Locating Element with Dynamic Text -


can me creating locator dymanic text here 0 dynmaic , can changed every execution of test script.

<a  title="mytest" href="/abc/test/page1">0   </a> 

here 0 dynamic , can changed different users. i'm using data-driven approach using excel input.

thanks

you can use following code:

webelement yourelement = driver.findelement(by.xpath(string.format("//a[contains(@title, 'mytest') , text()='{0}']", yourtext))); 

find element title + dynamic text passed string.format method.


Comments