學習Robot Framework必須掌握的庫----BuiltIn庫

Evaluate關鍵字:如果你需要進行一些數值運算并得到結果,你就需要用到Evaluate關鍵字。Evaluate會把你想要計算的表達式直接傳遞給Python,并把Python的計算結果返回給你。這是最經常要用到的。

Should 系列關鍵字:Should系列關鍵字是Should大頭的一系列關鍵字。

Should Be Empty·Should Be Equal·Should Be Equal As Integers·Should Be Equal As Numbers·Should Be Equal As Strings·Should Be True·Should Contain·Should Contain X Times·Should End With·Should Match·Should Match Regexp·Should Not Be Empty·Should Not Be Equal·Should Not Be Equal As Integers·Should Not Be Equal As Numbers·Should Not Be Equal As Strings·Should Not Be True·Should Not Contain·Should Not End With·Should Not Match·Should Not Match Regexp·Should Not Start With·Should Start With

這些關鍵字都是用作判斷時用的,每個用例都會用到,比如我們的執行結果得到了一個字符串,我們要判斷這個字符串要與一個預期字符串相等,否則用例就無法通過,這時候,肯定會用上 Should Be Equal As String

關鍵字,其它關鍵字我們通過關鍵字的名字就能顧名思義,知道它的作用。

Convert To系列關鍵字:

Convert To Binary·Convert To Boolean·Convert To Hex·Convert To Integer·Convert To Number·Convert To Octal·Convert To String

做類型轉換比不可少。

Run keyword系列關鍵字:

Run Keyword If·Run Keyword If All Critical Tests Passed·Run Keyword If All Tests Passed·Run Keyword If Any Critical Tests Failed·Run Keyword If Any Tests Failed·Run Keyword If Test Failed·Run Keyword If Test Passed·Run Keyword If Timeout Occurred·

這些關鍵字能根據一個判斷條件的真假來看是否執行關鍵字。一般使用這些關鍵字來實現高級語言中的if else功能。最常用的是Run Keyword If 和 Run Keyword unless他們倆實現的效果正好相反。

Exit For Loop關鍵字:

用作退出循環,一般和Run keyword if 關鍵字聯合使用,來實現條件退出。

Wait Until Keyword Succeeds

這是一個將異步調用變為同步調用的關鍵字。舉一個例子:如果call某個WebService,并且需要得到返回結果才能做下一部操作。我們就會用到這個關鍵字。

BuiltIn庫里還有很多寶貝,比如日期相關的關鍵字Get Time。讓測試暫停的Sleep等。都相當有用。還等什么?

去這個鏈接遍歷一遍它吧:)http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html

注1:RF目前僅有2個內置關鍵字:FOF 和 IN,來實現循環結構。功能還是比較弱的。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容