在使用自定义的robotframework关键字时,我遇到了一些让selenium2library在失败时触发运行的问题。
我用Python语言编写了一个关键字,它的工作方式与我预期的一样,但在引发AssertionError失败时,不会调用Selenium2Library的Run_On_Failure关键字。
我也尝试过将这个关键字包装在用户定义的Robotframework关键字中,但仍然无法让Run_On_Failure触发。然而,当我导致S2L关键字失败时,Run_On_Failure就会像我预期的那样生效。
当我的RFpy关键字失败时,我需要调用Run_On_Failure。有人有什么建议吗?
这是我的关键词
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!")发布于 2013-03-25 22:16:27
解决方案是一个内置的RF关键字,称为“如果测试失败,则运行关键字”。
https://stackoverflow.com/questions/15574074
复制相似问题