Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use xpath in Selenium RC with JavaScript?
    text
    copied!<p>I am using Selenium RC with IE 6 and XPath locators are terribly slow. So I am trying to see if javascript-xpath actually speeds up things.</p> <p>But could not find enough/clear documentation on how to use native x- path libraries.</p> <p>I am doing the following:</p> <pre><code>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"); } </code></pre> <p>This results in speed improvement of XPath locator but the improvements are not consistent. On some runs the time taken for a locator is halved; while sometimes its randomly high.</p> <p>Am I missing any configuration step here? Would be great if someone who has had success with this could share their views and approach.</p> <p>Thanks, Nirmal </p> <p><b>Solution:</b></p> <pre><code>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"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload