首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Run_on_failure + Selenium2Library原生Py关键字Robotframework

Run_on_failure + Selenium2Library原生Py关键字Robotframework
EN

Stack Overflow用户
提问于 2013-03-22 23:27:34
回答 1查看 526关注 0票数 0

在使用自定义的robotframework关键字时,我遇到了一些让selenium2library在失败时触发运行的问题。

我用Python语言编写了一个关键字,它的工作方式与我预期的一样,但在引发AssertionError失败时,不会调用Selenium2Library的Run_On_Failure关键字。

我也尝试过将这个关键字包装在用户定义的Robotframework关键字中,但仍然无法让Run_On_Failure触发。然而,当我导致S2L关键字失败时,Run_On_Failure就会像我预期的那样生效。

当我的RFpy关键字失败时,我需要调用Run_On_Failure。有人有什么建议吗?

这是我的关键词

代码语言:javascript
复制
    def compare_text(self, actualString, expectedString):
    """Compares two strings of text, this differs from the Selenium2Library
    text compare routines because we do not require an element locator, just
    the `actual` and `expected` strings.  String matching failure will cause
    the test to Assert an error and the test to fail.
    """
    print("Actual Here: %s") % (actualString)
    print("Expected Here: %s") % (expectedString)
    if actualString != expectedString:
        raise AssertionError("ERROR: Actual and Expected strings don't match!")
EN

回答 1

Stack Overflow用户

发布于 2013-03-25 22:16:27

解决方案是一个内置的RF关键字,称为“如果测试失败,则运行关键字”。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15574074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档