执行用于在selenium 2.43中突出显示和重置WebElement的脚本时:
public void highlightElement(WebElement element) {
String originalStyle = element.getAttribute("style");
JavascriptExecutor js = (JavascriptExecutor) selenium;
js.executeScript("arguments[0].setAttribute('style', arguments[1]);",element,
"color: red; border: 5px solid red;");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {}
js.executeScript("arguments[0].setAttribute('style', '" + originalStyle + "');", element);
}

Eclipse返回错误:
org.openqa.selenium.WebDriverException: arguments[0] is undefined
Command duration or timeout: 74 milliseconds
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=35.0}]

在Firefox 35更新后观察到此问题。有解决方法吗?
答案 0 :(得分:0)
在运行firefox 35时我也遇到了同样的问题。我将它降级为firefox 33,这对我有用。(https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/33.0/mac/en-US/)
使用firefox 33的Selenium服务器版本2.44.0解决了这个问题。