如何在乘骑机器人框架中处理try catch异常? [英] How to handle try catch exception in ride robot framework?

查看:91
本文介绍了如何在乘骑机器人框架中处理try catch异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 ...

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异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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