Issues in JavascriptExecutor | Selenium Forum
M
Posted on 20/04/2016
Hi,

I could not able to execute the JavaScript code in Selenium.

As I have followed the Training Module 16 - Part2. I can see the trainer using the below code to execute. when I try the same code I could not able to execute.

Trainer Code -- > ((JavascriptExecutor)driver).executeScript("alert('Hello')");

I am getting the below error when i try the same code : when i place my cursor on the "executeScript"
[b:2s4f41wk][i:2s4f41wk][u:2s4f41wk]The method executeScript(String, Object[]) in the type JavascriptExecutor is not applicable for the arguments (String)[/u:2s4f41wk][/i:2s4f41wk][/b:2s4f41wk]

If I add [b:2s4f41wk]"null"[/b:2s4f41wk] as a second parameter. Error disappear and when I run my code. I am getting [b:2s4f41wk]"NullPointerException"[/b:2s4f41wk]
[b:2s4f41wk][i:2s4f41wk][u:2s4f41wk]((JavascriptExecutor)wd).executeScript("alert('Hello')",null);[/u:2s4f41wk][/i:2s4f41wk][/b:2s4f41wk]

Please help me to reslove this issue.

Thanks
Ananth T

M
Replied on 21/04/2016

send me the entire code.