Selenium.getText() problem
Hope someone can help me here?
Having an issue getting text that's located inside a tag but After another tag...
<li><b>**Duration Held:**</b> 5 Years </li>
I need to return the "5 Years" part of the Text but selenium.getText() returns the whole <li>
contents, which is correct, but I need the text after the </b>
tag but can't figure out a way to achieve this task?
Has anyone come across this type of scenario, if so, what was done to get the text after a </b>
but still inside the <li>
tag ???
I'm stumped, Any help i开发者_开发技巧s appreciated!
Cheers!
You can easily use regex to extract what you want. such as;
String st = selenium.getText();
Pattern pt = Pattern.compile("</b>([^<]+)</li>");
Matcher matcher = pt.matcher(st);
if (matcher.matches())
System.out.println(matcher.group(1));
精彩评论