Hi
Anyone knows how I can iterate a text/string in an XPATH
EX:
//span[contains(text(),‘Analytics & Machine Learning’)]
The part of Analytics & Machine Learning will always be changing with a list of Data sets.
Sorry I don’t know if that is possible, I’m bit new with automation and in Katalon. Hope you can help me. TY
We may need more information to give you a better idea, such as how many different Data sets. I ask this because it would be simple to create a new TestObject for a run putting in the different xpaths within a CASE block. The concern is how many blocks; a few and this method would be okay. Too many and then you would need to read the pathways in from a source and build that way.
TestObject myNewObject = new TestObject('')
switch(expression) {
case exp1:
myNewObject.setSelectorValue(SelectorMethod.XPATH,'//span[contains(text(),"Analytics & Machine Learning")]')
case exp2:
myNewObject.setSelectorValue(SelectorMethod.XPATH,'//span[contains(text(),"Men & Their Flying Machines")]')
default:
myNewObject.setSelectorValue(SelectorMethod.XPATH,'//span[contains(text(),"Some where")]')
}
myNewObject.setSelectorMethod(SelectorMethod.XPATH)
for(String text : listOfTexts) {
String xpath = "//span[contains(text(),'" + text + "')]";
}