2013-03-22 29 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關鍵字。

相關問題