我使用IE 6和XPath的Selenium RC非常慢,速度很慢。 所以我想看看如果JavaScript-xpath实际上加快了速度。如何在JavaScript中使用Selenium RC中的xpath?
但是找不到足够/清晰的关于如何使用本机x- 路径库的文档。
我做了以下内容:
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");
}
喜丹, 如果我们不明确添加脚本;发动机从哪里来?硒是否已经包含这个js?我无法找到任何这样的证据。 – 2010-03-30 05:55:40
如果你看一下Selenium的源代码,你会发现javascript-xpath-0.1.11.js被包含在普通的\ src \ js \ core \ xpath中,所以我假设它正在从中拉出。 SOMETHING导致我的测试速度提高了7倍。 =) – 2010-03-30 22:02:55