Appium-Execute Async(执行异步)

Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame (Web context only) //将JavaScript片段插入到页面中,以便在当前选定框架的环境中执行(仅限Web环境)

Example Usage
Java((JavascriptExecutor) driver).executeAsyncScript("window.setTimeout(arguments[arguments.length - 1], 500);");
Pythonself.driver.execute_async_script(‘document.title’)
Javascript// webdriver.io example
driver.setAsyncTimeout(5000)
var result = browser.executeAsync(function(a, b, c, d, done) {
// browser context - you may access neither client nor console
setTimeout(function() {
done(a + b + c + d);
}, 3000);
}, 1, 2, 3, 4)

// node.js context - client and console are available
console.log(result); // outputs: 10

// wd example
await driver.safeExecuteAsync('document.title');
Ruby# ruby_lib example
execute_async_script("document.title")

# ruby_lib_core example
@driver.execute_async_script("document.title")
C#// TODO C# sample
PHP// TODO PHP sample
Description

The executed script is assumed to be asynchronous and must signal that is done by invoking the provided callback, which is always provided as the final argument to the function. The value to this callback will be returned to the client.
//假定执行的脚本是异步的,并且必须通过调用提供的回调来发出信号,该回调始终作为函数的最终参数提供。此回调的值将返回给客户端

Asynchronous script commands may not span page loads. If an unload event is fired while waiting for a script result, an error should be returned to the client.
//异步脚本命令不能跨越页面加载。如果在等待脚本结果时触发卸载事件,则应向客户端返回错误

The script argument defines the script to execute in teh form of a function body. The function will be invoked with the provided args array and the values may be accessed via the arguments object in the order specified. The final argument will always be a callback function that must be invoked to signal that the script has finished.
//异步脚本命令不能跨越页面加载。如果在等待脚本结果时触发卸载事件,则应向客户端返回错误。script参数定义以函数体形式执行的脚本

Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement reference will be converted to the corresponding DOM element. Likewise, any WebElements in the script result will be returned to the client as WebElement JSON objects.
//如果在等待脚本结果时触发卸载事件,则应向客户端返回错误。script参数定义以函数体形式执行的脚本。将使用提供的args数组调用该函数,并且可以按指定的顺序通过arguments对象访问这些值

Support
Appium Server
PlatformDriverPlatform VersionsAppium VersionDriver Version
iOSXCUITestNoneNoneNone
UIAutomationNoneNoneNone
AndroidEspressoNoneNoneNone
UiAutomator2NoneNoneNone
UiAutomatorNoneNoneNone
MacMacNoneNoneNone
WindowsWindowsNoneNoneNone
Appium Clients
LanguageSupportDocumentation
JavaAllseleniumhq.github.io
PythonAllselenium-python.readthedocs.io
Javascript (WebdriverIO)All
Javascript (WD)Allgithub.com
RubyAllwww.rubydoc.info
PHPAllgithub.com
C#Allgithub.com
HTTP API Specifications
Endpoint

POST /session/:session_id/execute_async

URL Parameters
namedescription
session_idID of the session to route the command to
JSON Parameters
nametypedescription
scriptstringThe script to execute
argsarrayThe script arguments
Response

The script result (any)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: appium-python-client安装包可以通过pip命令进行安装,具体步骤如下: 1. 打开命令行工具(如Windows下的cmd或者Linux下的终端),输入以下命令安装pip: ``` sudo apt-get install python-pip ``` 2. 安装appium-python-client,输入以下命令: ``` pip install Appium-Python-Client ``` 3. 等待安装完成即可使用appium-python-client。 ### 回答2: appium-python-client是一个用于进行移动应用测试的Python库。它作为Appium测试框架的一个客户端,提供了许多功能和方法来编写和执行测试脚本。 要安装appium-python-client,需要先确保已经安装了Python环境。以下是安装appium-python-client的步骤: 1. 打开终端或命令提示符,并进入到所需的Python项目目录。 2. 使用pip命令安装appium-python-client。在终端或命令提示符中输入以下命令: pip install Appium-Python-Client 在执行命令后,pip会从Python Package Index(PyPI)上下载并安装appium-python-client。 安装完成后,您可以在Python脚本中导入appium-python-client并开始编写测试代码。 例如,您可以使用以下命令导入appium-python-client库: ```python from appium import webdriver ``` 然后,您可以使用appium-python-client提供的方法来启动Appium服务器、初始化移动设备连接、定位元素,并执行各种移动应用测试操作。 总结: appium-python-client是一个用于进行移动应用测试的Python库,可以通过pip命令进行安装。安装完成后,您可以在Python脚本中导入该库并使用其提供的方法来编写和执行移动应用测试脚本。 ### 回答3: appium-python-client是一个用于与Appium服务器进行通信的Python库。要安装appium-python-client,您可以按照以下步骤进行操作: 1. 确保您的电脑已经安装了Python解释器。您可以通过在命令行中输入“python --version”来验证Python是否已经安装。 2. 打开命令行或终端,并输入以下命令来安装appium-python-client: ``` pip install Appium-Python-Client ``` 注意:您需要确保您的电脑已经安装了pip,它是一个用于安装Python库的包管理工具。如果您的电脑上没有安装pip,您可以通过以下命令来安装它: ``` python -m ensurepip --upgrade ``` 3. 安装完成后,您可以在Python脚本中导入appium-python-client模块并使用它来与Appium服务器进行通信。例如,您可以使用以下代码示例来连接到Appium服务器: ```python from appium import webdriver desired_caps = { 'platformName': 'Android', 'platformVersion': '9', 'deviceName': 'Android Emulator', 'app': 'path/to/your/app.apk' } driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) ``` 这将创建一个WebDriver实例,用于控制连接到Appium服务器的设备。您可以使用WebDriver实例来执行各种测试操作,例如查找元素、发送输入等。 通过按照以上步骤安装appium-python-client,您就可以在Python中使用它来创建和执行Appium测试。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aniona

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值