What does arguments[0]
and arguments[1]
mean when using executeScript()
method from JavascriptExecutor interface through Selenium WebDriver and what is the purpose of the arguments[0]
in the下面的代码。
javaScriptExecutor.executeScript("arguments[0].click()", webElement);
原文由 Vel Guru 发布,翻译遵循 CC BY-SA 4.0 许可协议
JavascriptExecutor 接口中的 executeScript() 方法可以以 arguments[0] 、 arguments[1] 等形式调用多个参数
javaScriptExecutor.executeScript("arguments[0].click()", webElement);
工作,您需要定义 webElement 。executeScript()
方法将元素的引用作为 参数 [0] 以及要执行的 方法[在这种情况下click()
] 并且此后应提供引用。executeScript()
的示例如下:在这个例子中:
driver.findElement(By.xpath("//input[@type='file']
被称为 参数[0]