运行JavascriptExecutor时出现空指针异常

时间:2019-06-09 10:54:49

标签: selenium selenium-webdriver

当我尝试运行JavascriptExecutor时,出现空指针异常。请在下面找到我的代码。我已经关注了stackoverflow的以下链接

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();
		}

请在下面找到错误

enter image description here

当我将值更改为以下内容时,我返回空值

字符串值1 =(字符串)(executor.executeScript(js));

0 个答案:

没有答案