我使用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