关键字“捕获页面截图"无法在失败时运行 [英] Keyword 'Capture Page Screenshot' could not be run on failure

查看:58
本文介绍了关键字“捕获页面截图"无法在失败时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用机器人框架运行自动化android应用程序:我已经导入了selenium2library和android库.最初,我使用goto url关键字启动了应用程序:我在此处将参数作为我的应用程序的网址.运行测试脚本后,我得到了::

I am running automating android apps using robot framework: i have imported libraries those are selenium2library and android library. Initially i launched apps using goto url keyword: where i gave argument as url of my apps. after running test script i got ::

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.

如何解决.谁能告诉我一些解决方法.

How to resolve it. Could anybody tell me some solutions.

推荐答案

机器人告诉您,有两个名为 Capture Page Screenshot 的关键字.一种是由 Selenium2Library 定义的,另一种是由 AppiumLibrary 定义的.其中一个或两个都已指示机器人在出现错误时运行 Capture Page Screenshot .但是,由于有两个,机器人不知道应该呼叫哪个.

Robot is telling you that there are two keywords named Capture Page Screenshot. One is defined by Selenium2Library, and one is defined by AppiumLibrary. One or both of those also have instructed robot to run Capture Page Screenshot when there is an error. However, because there are two, robot doesn't know which one it is supposed to call.

至少有两种解决方案.第一种是使用内置关键字设置库搜索顺序,以指示漫游器搜索关键字的顺序.第二个是明确告诉机器人要运行哪个版本.该解决方案可能也很简单,例如 not 将两个库都导入到单个套件中.

There are at least a couple of solutions. The first is to use the built-in keyword Set library search order, to instruct robot on the order in which to search for the keywords. The second is to tell robot specifically which version to run. The solution might also be as simple as not importing both libraries into a single suite.

要设置搜索顺序,请在测试开始时添加以下内容-可能是在套件设置中:

To set the search order, add something like this to the start of your test -- perhaps in the suite setup:

*** Settings ***
| Suite Setup | Set Library Search Order | AppiumLibrary | Selenium2Library

这指示机器人先检查 AppiumLibrary ,然后再检查 Selenium2Library 以解决冲突.

That instructs robot to first examine AppiumLibrary and then Selenium2Library to resolve conflicts.

从关键字文档中:

库搜索顺序用于解决关键字存在时的冲突测试数据中的名称与多个关键字匹配.第一个图书馆(或资源,请参见下文),然后选择包含该关键字的关键字使用关键字实现.如果找不到任何关键字库(或资源),测试执行失败的方式与搜索顺序未设置.

The library search order is used to resolve conflicts when a keyword name in the test data matches multiple keywords. The first library (or resource, see below) containing the keyword is selected and that keyword implementation used. If the keyword is not found from any library (or resource), test executing fails the same way as when the search order is not set.

设置明确的关键字名称

导入 Selenium2Library AppiumLibrary 时,您可以指定在失败时运行的命令.默认值为捕获页面截图,这是问题的根源,因为有两个具有该名称的关键字.您可以明确告诉机器人要使用哪个机器人.

Set explicit keyword name

When importing Selenium2Library and AppiumLibrary you can specify which command to run on failure. The default is Capture page screenshot, which is the root of the problem since there are two keywords with that name. You can tell robot explicitly which one to use.

例如:

*** Settings ***
| Library | Selenium2Library | run_on_failure=AppiumLibrary.CapturePageScreenshot
| Library | AppiumLibrary | run_on_failure=AppiumLibrary.CapturePageScreenshot

如果您不想更改导入库的方式,则每个库都还提供一个名为

If you do not wish to change how you import the library, each also provides a keyword named Register keyword to run on failure which you can use in a setup step to register the fully qualified keyword name.

这篇关于关键字“捕获页面截图"无法在失败时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆