你好,我正在尝试从 chrome 控制台这里获取这个值,但是 Selenium 给了我这个错误。
[main] ERROR io.qameta.allure.util.NamingUtils - Could not find parameter color
org.openqa.selenium.JavascriptException: javascript error: {"status":10,"value":"stale element not found in the current frame"}
这是我的代码:
public static JavascriptExecutor getJsExecutor() {
JavascriptExecutor js = (JavascriptExecutor) DriverManager.getDriver();
return js;
}
getJsExecutor().executeScript(
"console.log('selected element: ', window.pfSelected.state);"
);
Object response = getJsExecutor().executeScript("return window.pfSelected.state;");
浏览器控制台实际上注销了一个对象img
有什么方法可以从 Selenium 获得
pfSelected.state
值吗?
解决方案:必须是
return window.pfSelected.state.id
(字符串),而不是返回window.pfSelected.state
或window.pfSelected
(对象)。