robotframework.org
Core Validation
Variable
Set Variable VALUE ex : ${TOKEN} = Set Variable ${res.body['accessToken']}
Set Global Variable ${MY_VAR}
Logs
Log to console
Log Variables
Selenium SeleniumLibrary is a web testing library for Robot Framework.
Locating elements
Strategy
Match based on
Example
id
Element id.
id:example
or identifier:example
name
name attribute
name:example
or identifier:example
class
Element class.
class:example
tag
Tag name
tag:div
xpath
XPath expression
xpath://div[@id="example"]
//div[@id="foo"]//h1
(//div)[2]
//*[contains(text(), "example")]
css
CSS selector
css:div#example
Actions
Click Button
Click Element
Click Image
Click Link
Wait Until Element Is Visible
Run Keyword And Ignore Error Click Link //a[contains(@href,'sign-out')]
Select Frame (//iframe)[1]
Select first frame
1 2 3 Input Username [Arguments] ${username} Input Text username ${username}
Validation
Element Attribute Value Should Be
Element Should Be Enabled
Element Should Be Disabled
Element Should Be Visible
Element Should Contain : Use Element Text Should Be if you want to match the exact text, not a substring.
Get Text in HTML
Get Element Attribute${id}= Get Element Attribute css:h1 id
Get Text ${response} Get Text xpath=/html/body/div/tr[2]/td/strong
1 2 ${response} Get Text xpath =/html/body/div/tr[2]/td/strongShould Be Equal As Strings ${response} Payment was successful
REST
Exemples 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Library REST http: $ {MOBILE_TOKEN} aTokenAuthenticate Set Headers Get Authenticate &{res}= GET /rest//a4//getstoresdetails Log to console ${res.body[0 ].mondayFrom}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Library REST http: ${products} = {"products" : [{"sku" : "4011" , "quantity" : 3 }, {"sku" : "201201" , "pickingOptionCode" : "P01" , "pickingOptionSelectedValueCode" : "P0102" , "quantity" : 1 }, { "sku" : "059263020010" , "quantity" : 2 } ]}Authenticate &{res}= POST /api/authentication {"username" : "admin" ,"password" : "mypassword" } ${TOKEN} = Set Variable ${res .body['accessToken']} Set Global Variable ${TOKEN} # ${accessToken} = String response body accessToken # Set Global Variable ${accessToken} Create Collection with Products # Log Variables Set Headers { "authorization" : "Bearer ${TOKEN}" } POST api/products ${products} ${url} = String response body purchaseUrl Log to console ${url} Should Contain ${url [0]} monproduit?pcid= Get all users Authenticate Create Collection with Products
Integration avec Java
Acceptance Tests Writing Maintainable Automated Acceptance Tests