People who code: we want your input. Take the Survey

Hot answers tagged


You create a string String cityName = "London"; String data = "div[contains(text(),"+ "'"+cityName +"'"+")]"; System.out.println(data); You can put in a for loop and then use this data value as locator.


You can use the String replace method. String city = prop.getProperty("data"); // New Delhi String locatorTemplate = prop.getProperty("locatorKey"); // div[contains(text(),'<state Name>')] String locator = locatorTemplate.replace(locatorPattern, city); // div[contains(text(),'New Delhi')] WebElement element = ...

Only top voted, non community-wiki answers of a minimum length are eligible