After attempting to follow the steps outlined in this particular blog post in order to obtain a count of CSS locators, I encountered an issue with the method provided:
public static int getCSSCount(String cssLocator) {
String jsScript = "var cssMatches = eval_css(\"%s\", window.document);cssMatches.length;";
return Integer.parseInt(selenium.getEval(String.format(jsScript, cssLocator)));
}
The method call looked like this:
getCSSCount("div[class='team-name'] a");
Despite following the instructions precisely, I consistently faced the following exception:
FAILED: com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: unterminated string literal at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97) at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91) at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262) at com.thoughtworks.selenium.DefaultSelenium.getEval(DefaultSelenium.java:471)