Usually we can use the robot framework to write interface automation use cases, but some sites do not do the front-end separation, the iterative process has a lot of repetitive test work, there is no interface to call validation, there are automated test requirements, how to do? At this point, the Web UI Automation of the deep pit is imperative. Robot is just an automation framework, fortunately he is stable and extensibility is excellent, to drive a Web browser to work automatically, only need to install another artifact selenium, below the outline of the introduction of the Web UI how to get started, once you enter the door, the rest is the work of Baidu and crossing network help, Recommended to use in the check, or no eggs used.
Use Case Authoring Prerequisites:
- The ROBOT/PYTHON3 environment has been deployed, see:
- Install selenium, recommended 3.11.0 Version: Pip install selenium==3.11.0
- Install Robotframework-seleniumlibrary, recommended 3.1.1 version: Pip install robotframework-seleniumlibrary==3.1.1
- Install Webdriver, recommend the more popular chromedriver, download from here: http://chromedriver.storage.googleapis.com/index.html
Chromedriver version needs to be corresponding to the native Chrome browser for normal use, download the corresponding version of the Chromedriver driver file, the specific version of the corresponding relationship table:
Chromedriver Version | Supported versions of Chrome
v2.33 | v60-62
v2.32 | v59-61
v2.31 | V58-60
v2.30 | V58-60
v2.29 | v56-58
v2.28 | v55-57
v2.27 | v54-56
v2.26 | V53-55
v2.25 | V53-55
v2.24 | v52-54
v2.23 | v51-53
v2.22 | v49-52
v2.21 | V46-50
v2.20 | v43-48
v2.19 | v43-47
v2.18 | v43-46
v2.17 | v42-43
v2.13 | V42-45
Window platform, unzip and then put in the native Chrome file path, such as:
C:\Program Files (x86) \google\chrome\application
Or add the Chromedriver address to the system path.
Referencing the selenium package in a use case file
*** Settings ***Library CollectionsLibrary SeleniumLibrary
A sample is as follows:
*** Test Cases ***my first html #创建一个chrome浏览器 Open Browser http://www.我的域名.cn/ chrome #输入文本框 input text id=inputName admin input text id=inputPassword admin input text id=inputCode 123 #点击按钮 Click Button Xpath=//form/div/span/button #单击A标签 | locator表示定位器 #Click Link | locator #单击某个标签 #Click Element Xpath=//ul[@id=‘systemSetting0‘] ${cnt} get title log ${cnt} ${title} get window titles log ${title} Title Should Be 一个后台 Location should Contain http://www.我的域名.cn/ Page Should Not Contain 不包含我 Page Should Contain 必须包含我 # 关闭打开的浏览器 Close Browser Close All Browsers
Execute the use case you will see, a chrome automatically open, and enter a password, click on the login, it may be very fast to see clearly, in order to see the clarity, you can use the Sleep method at each step for a few seconds:
# 这里的单位是秒sleep 3
Of course, if your Web load is slow, with a few seconds to avoid is not reliable, it is recommended to use this method:
Wait Until Page Contains Element
Robot+selenium writing Web UI Automation use Cases