I am using StringUtils from the apache commons library to check the # of matches of a substring within the source code of an html page.
I have converted the page source using the webdriver command:
String pageSource = driver.getPageSource();
The code I am using to find # of matches is:
int cloudfCount = StringUtils.countMatches(pageSource, "cloudfront"); System.out.println("There are " + cloudfCount + " instances of cloudf text found within the page source.");
When I right-click within the page, view source, then ctrl-f to "find" cloudfront, I get 2 matches. Which is what I am expecting.
But when I use the above code in an automated Selenium script, I am getting 5 results.
Any thoughts/ideas on where I'm going wrong?