art_tykh
art_tykh

Reputation: 169

Get Firebug console output using Selenium WebDriver

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.

Upvotes: 1

Views: 423

Answers (1)

peetya
peetya

Reputation: 3628

Add the "return" string before your command:

Object jsResult = ((JavascriptExecutor) driver).executeScript("return" + command);
return (jsResult == null ? null : jsResult.toString());

Upvotes: 1

Related Questions