gpt4 book ai didi

javascript - 如何在带有 JavaScript 的 Selenium RC 中使用 xpath?

转载 作者:数据小太阳 更新时间:2023-10-29 04:46:52 24 4
gpt4 key购买 nike

我在 IE 6 上使用 Selenium RC,XPath 定位器非常棒减缓。所以我想看看 javascript-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");
}

最佳答案

我自己实现了这个,我只需要做 selenium.useXpathLibrary("javascript-xpath")。在我的测试中,javascript xpath 在 IE 8 上快了大约 7 倍。还没有真正测试过其他任何东西,但我们只将它用于 IE。

关于javascript - 如何在带有 JavaScript 的 Selenium RC 中使用 xpath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2536652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com