当我尝试运行JavascriptExecutor时,出现空指针异常。请在下面找到我的代码。我已经关注了stackoverflow的以下链接
Selenium Javascript executor returns null
driver.executeScript() returns NullPointerException for simple javascript
public void CallApi() {
try {
String result = null;
Thread.sleep(d);
JavascriptExecutor executor = (JavascriptExecutor) driver;
String r1 = Uuid(result);
System.out.println(r1);
String value = (String) (executor.executeScript("return ContentAPI.getReport('" + r1
+ "').registerOutputType('dataset', function(data) { console.log(data) });"));
System.out.println(value);
String js = "function DrillDown() { ContentAPI.getReport('" + r1
+ "').drill('Agency Type', 'Online')}; return DrillDown()";
long value1 = (long) (executor.executeScript(js));
System.out.println(value1);
} catch (InterruptedException e) {
e.printStackTrace();
}
请在下面找到错误
当我将值更改为以下内容时,我返回空值
字符串值1 =(字符串)(executor.executeScript(js));