1

I am getting null pointer exception when I try to run JavascriptExecutor. Please find my code below. I have followed the following links from 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();
		}

Please find the error below

enter image description here

when I change the value to as per the following I get null returned

String value1 = (String) (executor.executeScript(js));

3
  • is the JS snippet in question pure or does it need any dependent js files like Jquery or something? Commented Jun 9, 2019 at 17:34
  • String js = "function DrillDown() { ContentAPI.getReport('" + r1 + "').drill('Agency Type', 'Online')}; return DrillDown()"; don't see any return value in this line. Commented Jun 9, 2019 at 18:49
  • there is no dependent jquery Commented Jun 9, 2019 at 23:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.