问题描述
我正在使用RIDE robotframework,我想在应用程序崩溃时处理异常,我将其关闭,然后打开它的新实例.
I'm using RIDE robotframework, i want to handle an exception when the application is crashed i close it then open a new instance of it.
*** Settings ***
Library SikuliLibrary
*** Variables ***
${openProject} sikuli_captured\\Emna\\openProject.png
${DataBaseSTProject} sikuli_captured\\Emna\\DataBaseSTProject.png
${testSession} sikuli_captured\\Emna\\testSession.png
${menu} sikuli_captured\\menu.png
${fileName} sikuli_captured\\Emna\\fileName.png
${save} sikuli_captured\\Emna\\save.png
*** Test Cases ***
createNewProject
Click ${menu}
Click ${testSession}
Input Text ${fileName} FirstProjecT3
Click ${save}
openTestProject
Click ${openProject}
Double Click ${DataBaseSTProject}
任何建议将不胜感激.
感谢您的帮助:)
推荐答案
在Robot Framework中,没有出现 Try/Catch/Finally 的概念.从本质上讲,您的Test Case body
是此三连击的 Try 部分,另外两个结合到相应的测试套件,测试用例或关键字部分.
In Robot Framework the concept of Try/Catch/Finally is not present. In essence your Test Case body
is the Try part of this trifecta and the other two are combined into the [Teardown]
keywords of the respective Test Suite, Test Case or Keyword sections.
在此Teardown关键字中,可以通过Run Keyword If ... 关键字家族.最后,您可以为Catch创建一个单独的部分.在下面的代码部分中,给出了通过和失败测试用例的示例,每个案例都使用相同的拆解.
Within this Teardown keyword it is possible to recognize if a Test Case has Passed or Failed through the automatic variables of Robot Framework itself or the Run Keyword If ...
family of keywords. This would allow you to create a separate section for the Catch, and finally. In the below section of code an example is given of a pass and fail test case, each using the same Teardown.
此构造应允许您检查测试用例中的步骤是否失败,验证应用程序是否已崩溃(通过弹出窗口的Sikuli图像测试),然后关闭并重新启动应用程序.
This construct should allow you to check if a step in a test case failed, verify if the application has crashed (through the Sikuli image test of the popup) and then close and restart the application.
*** Test Cases ***
Open Application and fail
Log to Console About to Fail
Fail
Log to Console Will never trigger.
[Teardown] Generic Test Case Teardown
Open Application and Pass
Log to Console About to Pass
No Operation
Log to Console Will trigger.
[Teardown] Generic Test Case Teardown
*** Keywords ***
Generic Test Case Teardown
# Catch of Try Catch Finally
Run Keyword If Test Failed Test Case Catch
# Finally of Try Catch Finally
# RKITS is only executed when test passed.
Run Keyword If Test Passed Test Case Finally
# Always executed regardless of test execution status.
Log To Console I am always executed.
Test Case Catch
Log To Console Test Case Catch
Test Case Finally
Log To Console Test Case Finally
这篇关于如何在乘骑机器人框架中处理try catch异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!