我在 IE 6 中使用 Selenium RC,而 XPath 定位器非常慢。所以我想看看 javascript-xpath 是否真的加快了速度。
但是找不到关于如何使用本机 x-path 库的足够/清晰的文档。
我正在执行以下操作:
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");
}