Reputation: 21
So I just did the "How to handle hidden web elements using the JavaScript executor method".
But I am still confused about the method
public static void selectDateByJS(WebDriver driver, WebElement element, String dateVal) {
JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("arguments[0].setAttribute('value', '" + dateVal + "');", element);
}
What does the argument[0]
represent? What does it mean?
Upvotes: 0
Views: 1154
Reputation: 36331
arguments[x]
is a way to reference the parameters passed to a function/method.
Since arguments
is an object you can access the values via their key.
Using this can be helpful when there are no parameters yet parameters have been passed in, for example: infinite arguments.
function myFunction() {
console.log('all', arguments)
console.log('first', arguments[0])
console.log('second', arguments[1])
console.log('third', arguments[2])
}
myFunction('a', 0, true)
Upvotes: 1