如果链接不存在,如何跳过测试用例并转到机器人框架中的下一个链接 [英] How to skip a testcase if a link is not present and go to next link in Robot framework

查看:44
本文介绍了如果链接不存在,如何跳过测试用例并转到机器人框架中的下一个链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:主页中有 5 个链接:链接 1链接 2链接 3链接 4链接 5

Scenario: There are 5 Links in the Home page: Link 1 Link 2 Link 3 Link 4 Link 5

以上每个链接都是单独的测试用例,所以总共有5个测试用例.

Each of the above links are separate test cases, so there are a total of 5 test cases.

根据要求,所有链接可能不会出现在所有站点中.

All the links may not present in all the sites, according to the requirements.

所以我需要编写一个 Robot 框架 测试用例,它可以动态地适用于所有站点,比如 1 个站点可能有 3 个链接,只有一些站点拥有所有 5 个链接.因此,如果该 lisk 不存在,则就像跳过特定的测试用例一样.

So I need to write a Robot framework test case which works dynamically for all the sites, Like 1 site may have 3 links only some has all the 5 links. So its like SKIPPING a particular Test case if that lisk is not present.

*** Keywords ***
Go to Manage Client Reports
Click Link    link:Manage Client Reports

谁能帮忙.

推荐答案

在即将推出的Robot FrameworkRelease 4.0 将引入新的测试状态skiped.以下是有关发布的简要状态:

In the upcoming Robot Framework Release 4.0 a new test status skipped will be introduced. Here is a brief status about the release:

逾期 27 天已完成 87%

Past due by 27 days 87% complete

主要发布专注于添加跳过状态 (#3622), IF/ELSE(#3074) 和增强侦听器 API (#3296 和 #3538).最后一个专业发布以支持 Python 2.

Major release concentrating on adding the skip status (#3622), IF/ELSE (#3074) and enhancing the listener API (#3296 and #3538). Last major release to support Python 2.

所以它现在可以随时准备就绪.

So it can be ready any time soon now.

这就是您可以拥有的 SKIP 状态 #3622.将有一个 Skip If 和一个 Skip 关键字和更多使用.

This is what you can have New SKIP status #3622. There will be a Skip If and a Skip keywords and more to be used.

如何跳过测试

将会有多种方式:

  • 库关键字可用于标记要跳过的单个测试的特殊异常.另见#3685.
  • 利用上述异常的内置关键字 Skip(或 Skip Test 和 Skip Task).
  • 内置 keyowrd Skip If 根据条件跳过.
  • 在套件设置中使用跳过异常时,套件中的所有测试都将被跳过.
  • 命令行选项 --skip 无条件跳过基于标签的测试.类似于 --exclude 但跳过的测试显示在日志/报告中具有跳过状态并且没有完全退出执行.
  • 命令行选项 --skiponfailure 如果测试失败则跳过测试.与当前的 --noncritical 效果类似.

关键性怎么样

正如在 #2087 中已经讨论过的,跳过状态是非常相似的功能比机器人当前的临界概念.有很多人想要两者兼而有之,但我认为这不是一个好主意相信在添加跳过时最好删除关键性.单独的问题 #3624 涵盖了消除关键性并在更多详情.颜色

As already discussed in #2087, the skip status is very similar feature than Robot's current criticality concept. There are many people who would like to have both, but I don't think that's a good idea and believe it's better to remove criticality when skipping is added. Separate issue #3624 covers removing criticality and explains this in more detail. Colors

跳过状态需要特定颜色来匹配当前通过(绿色)和失败(红色).黄色感觉像是一个有红绿灯的好人选比喻,但我对其他想法持开放态度,我们可能会改变其他颜色也是如此.可能也应该使颜色可配置-目前仅报告背景颜色支持.

Skip status needs a specific color to match current pass (green) and fail (red). Yellow feels like a good candidate with a traffic light metaphor, but I'm open for other ideas and we could possibly change other colors as well. Probably should make colors configurable too -- currently only report background colors support it.

上面提到的报表背景颜色也需要一些思考.目前它是绿色或红色,但添加了跳过状态,我们也可以使用黄色或我们决定使用的任何跳过颜色.列出了可以使用不同颜色的不同场景下面(假设绿色/黄色/红色方案):

Report background color mentioned above needs some thinking as well. Currently it's either green or red, but with the added skip status we could use also yellow or whatever skip color we decide to use. Different scenarios where different colors could be used are listed below (assuming green/yellow/red scheme):

  • 所有测试均通过.这是天然绿色.
  • 任何测试都失败了.这是自然的红色.
  • 跳过任何测试(没有失败).这可能应该是绿色,但也可能是黄色.
  • 已跳过所有测试.这可能是黄色的.也可能是绿色的,但如果所有测试都是黄色的,那就有点奇怪了.

根据您的截止日期,您可能无法等待此版本,但了解这一点是件好事.

Depending on your deadlines you might won't be able to wait this release, nevertheless it is a good to know thing.

这篇关于如果链接不存在,如何跳过测试用例并转到机器人框架中的下一个链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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