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

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

问题描述

我正在使用机器人框架运行自动化 android 应用程序:我已经导入了 selenium2library 和 android 库.最初我使用 goto url 关键字启动应用程序:我将参数作为我的应用程序的 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.

推荐答案

Robot 告诉您有两个关键字名为 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.

至少有几个解决方案.首先是使用内置关键字设置库搜索顺序,指示机器人搜索关键字的顺序.二是具体告诉机器人运行哪个版本.解决方案也可能很简单,将两个库导入到一个套件中.

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.

设置明确的关键字名称

在导入 Selenium2LibraryAppiumLibrary 时,您可以指定在失败时运行哪个命令.默认为Capture page screenshot,这是问题的根源,因为有两个关键字同名.您可以明确告诉机器人要使用哪个.

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天全站免登陆