sun*_*nil 1 robotframework appium
我正在使用机器人框架运行自动化 android 应用程序:我导入了 selenium2library 和 android 库。最初我使用 goto url 关键字启动应用程序:我将参数作为我的应用程序的 url 给出。运行测试脚本后,我得到 ::
Keyword 'Capture Page Screenshot' could not be run on failure:
Multiple keywords with name 'Capture Page Screenshot' found. Give
the full name of the keyword you want to use:
AppiumLibrary.Capture Page Screenshot
Selenium2Library.Capture Page Screenshot.
Run Code Online (Sandbox Code Playgroud)
如何解决。谁能告诉我一些解决方案。
Robot 告诉您有两个关键字名为Capture Page Screenshot. 一个由 定义Selenium2Library,一个由 定义AppiumLibrary。Capture Page Screenshot当出现错误时,其中之一或两者也指示机器人运行。然而,因为有两个,机器人不知道它应该调用哪一个。
至少有几个解决方案。第一种是使用内置关键字Set library search order,指示机器人搜索关键字的顺序。二是具体告诉机器人运行哪个版本。解决方案也可能像不将两个库导入单个套件一样简单。
要设置搜索顺序,请在测试开始时添加如下内容——可能在套件设置中:
*** Settings ***
| Suite Setup | Set Library Search Order | AppiumLibrary | Selenium2Library
Run Code Online (Sandbox Code Playgroud)
这指示机器人首先检查AppiumLibrary然后Selenium2Library解决冲突。
从关键字文档:
当测试数据中的关键字名称匹配多个关键字时,使用库搜索顺序来解决冲突。选择包含关键字的第一个库(或资源,见下文)并使用该关键字实现。如果未从任何库(或资源)中找到关键字,则测试执行失败的方式与未设置搜索顺序时相同。
导入时Selenium2Library,AppiumLibrary您可以指定在失败时运行哪个命令。默认值为Capture page screenshot,这是问题的根源,因为有两个关键字具有该名称。您可以明确告诉机器人使用哪个。
例如:
*** Settings ***
| Library | Selenium2Library | run_on_failure=AppiumLibrary.CapturePageScreenshot
| Library | AppiumLibrary | run_on_failure=AppiumLibrary.CapturePageScreenshot
Run Code Online (Sandbox Code Playgroud)
如果您不想更改导入库的方式,每个库还提供了一个名为Register 关键字以在失败时运行的关键字,您可以在设置步骤中使用它来注册完全限定的关键字名称。
| 归档时间: |
|
| 查看次数: |
9743 次 |
| 最近记录: |