return super.getEval(script);
我想在执行java脚本后返回字符串
(String)((JavascriptExecutor)this).executeScript(jsExpression)
答案 0 :(得分:0)
尝试使用它:
public void trigger(String script, WebElement element) {
((JavascriptExecutor) driver).executeScript(script, element);
}
public Object trigger(String script) {
return ((JavascriptExecutor) driver).executeScript(script);
}
使用它:
//get value
String script = "return document.getElementsByTagName('input')[0].value;";
//get text
String script = "return document.getElementsByTagName('p')[0].innerHTML;";
Object elementValue = trigger(script);
String value = (String) elementValue;
//use some element
WebElement element = driver.findElement(By.id("someId"));
trigger("arguments[0].click();", element);