I'm writing a selenium webdriver java test and trying to count the number of names that appear without the last name following it.
For example, any time "John Smith" appears, it wouldn't be counted, but if it was a sentence like "John did this", since Smith didn't appear, it would increase the count.
Unfortunately at this point, trying to read/count from a WebElement is returning a 0 no matter what I do, but I know either way I wouldn't be excluding the last name entries. Any suggestions welcome!
Current code:
//get string from WebElement text
`String john = JohnSmith.getText();
int johnCount =0;
while (john.contains("john")){
johnCount++;
//this line starts from the substring after the first john
john = john.substring(john.indexOf("john") + "john".length());
}