Reputation: 169
I want to use some values for my Selenium test. I can easily get this values via Firebug console
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.
Upvotes: 1
Views: 423
Reputation: 3628
Add the "return" string before your command:
Object jsResult = ((JavascriptExecutor) driver).executeScript("return" + command);
return (jsResult == null ? null : jsResult.toString());
Upvotes: 1