我正在嘗試使用this博客帖子。獲取CSS定位器的數量。但沒有利用,方法 -無法獲取CSSCount工作
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)));
}
和方法的調用 -
getCSSCount("div[class='team-name'] a");
但我總是會遇到以下情況例外 -
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)
你可以發佈你正在計算的CSS定位器的HTML嗎? – rs79 2011-04-26 13:42:26