1

I want to use some values for my Selenium test. I can easily get this values via Firebug consoleenter image description here

I was trying to do it using JavascriptExecutor:

 public void getSomeValue() {
    String command = "screenX"
    Object jsResult = ((JavascriptExecutor) driver).executeScript(command);
    System.out.println(jsResult.toString());
 }

But I've got java.lang.NullPointerException.

Can anybody explain me - why?

Thanks.

1 Answer 1

1

Add the "return" string before your command:

Object jsResult = ((JavascriptExecutor) driver).executeScript("return" + command);
return (jsResult == null ? null : jsResult.toString());
Sign up to request clarification or add additional context in comments.

Comments

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.