2013-03-22 70 views
0

我在使用自定义robotframework关键字时遇到一些问题,导致selenium2library触发失败时运行。Robotframework + Selenium2Library本机Py关键字Run_on_failure

我在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!") 

回答

1

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

相关问题