What Is The Use Of "arguments[0]" When Implementing Javascriptexecutor?
I have implemented successfully JavascriptExecutor but I want to know why we take this array 'arguments[0]'? Here is the code below: IJavaScriptExecutor executor = (IJavaScriptExe
Solution 1:
Check the definition from Selenium ExecuteScript page
The arguments will be made available to the JavaScript via the "arguments" magic variable, as if the function were called via "Function.apply"
and the returning value of executeScript is:
Returns: One of Boolean, Long, String, List or WebElement. Or null.
which means that returning object is a list and you can interact with by arguments[0]
magic variable.
Solution 2:
It is a reference to the arguments you pass in. In this case the index is 0 because you're passing in the element reference as the 0th argument in the executeScript call (the parameter after the String containing the script).
Post a Comment for "What Is The Use Of "arguments[0]" When Implementing Javascriptexecutor?"