我正在使用Selenium RC和IE 6,XPath定位器非常缓慢。因此,我正在尝试查看javascript-xpath是否可以加速操作。
但是,我找不到足够/清晰的文档来了解如何使用本地xpath库。
我正在执行以下操作:
protected void startSelenium (String testServer, String appName, String testInBrowser){
selenium = new DefaultSelenium("localhost", 4444, "*" +testInBrowser, testServer+ "/"+ appName + "/");
echo("selenium instance created:"+selenium.getClass());
selenium.start();
echo("selenium instance started..." + testServer + "/" + appName +"/");
selenium.runScript("lib/javascript-xpath-latest-cmp.js");
selenium.useXpathLibrary("javascript-xpath");
selenium.allowNativeXpath("true");
}
这会提高XPath定位器的速度,但改进并不一致。在某些运行中,定位器所需的时间减半;而有时则会随机变高。
我是否遗漏了任何配置步骤?如果有人成功过,请分享他们的看法和方法。
谢谢, 尼尔马尔
解决方案:
protected void startSelenium (String testServer, String appName, String testInBrowser){
selenium = new DefaultSelenium("localhost", 4444, "*" +testInBrowser, testServer+ "/"+ appName + "/");
echo("selenium instance created:"+selenium.getClass());
selenium.start();
echo("selenium instance started..." + testServer + "/" + appName +"/");
selenium.useXpathLibrary("javascript-xpath");
}