I am trying to understand the meaning of the following declaration:

JavascriptExecutor js = (JavascriptExecutor) driver; 

I know that the left side means to create an identifier js with type as JavascriptExecutor, but I am unable to understand what the right-hand syntax means

I read like JavascriptExecutor is an interface and that interfaces cannot be initialized. So what does the code actually does here


Drivers seems implementations of JavascriptExecutor. So it can be type casting.

https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html . You could read more about this at the mentioned link

enter image description here

  • 1
    @PDHide Thank you for your editing. – junghan Jun 27 '19 at 7:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.