Hello,
I have a working Selenium IDE script that is working using this code:
getEval | this.page().findElement('xpath=//html/body/div[18]/div[9]/div[2]/div/div[9]/div[2]/center/div/div/div[2]/div/span/span/a').removeAttribute('target')
I then exported the entire test case as a Junit test case. The command for the getEval was not included with the export. I tried the following code:
if (driver instanceof JavascriptExecutor) {
js = (JavascriptExecutor)driver;
}
js.executeScript("this.page().findElement('xpath=//html/body/div[18]/div[9]/div[2]/div/div[9]/div[2]/center/div/div/div[2]/div/span/span/a').removeAttribute('target');");
When running this line of code, I get and exception: page is not defined
I have also tried:
sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
sel.getEval("page().findElement('xpath=//html/body/div[18]/div[9]/div[2]/div/div[9]/div[2]/center/div/div/div[2]/div/span/span/a').removeAttribute('target')");
The Junit test crashes when this line in ran, and the test case fails. I was wondering if I am sending the correct javascript script or if there is another, better, way of doing such a Selenium command through java.
I am using java 6 and Selenium 2.33.0