What does arguments[0] and arguments[1] mean when using executeScript method from JavascriptExecutor interface through Selenium WebDriver?(通过 Selenium WebDriver 从 JavascriptExecutor 接口使用 executeScript 方法时,arguments[0] 和 arguments[1] 是什么意思?)
问题描述
使用 executeScript() 方法时,arguments[0] 和 arguments[1] 是什么意思JavascriptExecutor 接口通过 Selenium WebDriver 以及下面代码中 arguments[0] 的用途.
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 below code.
javaScriptExecutor.executeScript("arguments[0].click()", webElement);
推荐答案
executeScript() 方法来自 JavascriptExecutor 接口可以调用多个参数arguments[0]、arguments[1]等形式
根据您的示例,
javaScriptExecutor.executeScript("arguments[0].click()", webElement);需要 webElementem> 定义.executeScript()方法将元素的引用作为 arguments[0] 以及 method 被执行 [在这种情况下click()] 并且应该在之后提供参考.
As per your example, to
javaScriptExecutor.executeScript("arguments[0].click()", webElement);to work you need to have the webElement defined.executeScript()method will take the reference of the element as arguments[0] along with the method to be performed [in this caseclick()] and the reference should be provided thereafter.
WebElement webElement = driver.findElement(By.xpath("xpath_element"));
JavascriptExecutor javaScriptExecutor = (JavascriptExecutor)driver;
javaScriptExecutor.executeScript("arguments[0].click()", webElement);
同样地,一个带有多个arguments[]的executeScript()示例如下:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style', arguments[1])", driver.findElement(By.xpath("//input[@type='file']")), "0");
在这个例子中:
driver.findElement(By.xpath("//input[@type='file']被称为arguments[0]- 0"被称为arguments[1]
您可以在 通过 Selenium 和 Python 通过 WebDriver 实例调用 execute_script() 方法时的 arguments[0] 是什么?
这篇关于通过 Selenium WebDriver 从 JavascriptExecutor 接口使用 executeScript 方法时,arguments[0] 和 arguments[1] 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过 Selenium WebDriver 从 JavascriptExecutor 接口使用 executeScript 方法时,arguments[0] 和 arguments[1] 是什么意思?
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
