Robot simple introduce

一. Simple introduction
Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). It has easy-to-use tabular test data syntax and it utilizes the keyword-driven testing approach. Its testing capabilities can be extended by test libraries implemented either with Python or Java, and users can create new higher-level keywords from existing ones using the same syntax that is used for creating test cases.

二. Set up
1.Python
    $ python --version
    Python 2.6.6

2.Robot Framework
(1)Download "robotframework-2.8.6.tar.gz"

https://pypi.python.org/pypi/robotframework .
(2)tar zxf robotframework-2.8.6.tar.gz
(3)cd robotframework-2.8.6
(4)python setup.py install
(5)Use following command to verify whether we have installed successfully:
$ pybot --version
Robot Framework 2.8.6 (Python 2.6.6 on linux2)

3.WxPython
(1)Download "wxPython-2.8.12.0-1.el6.x86_64.rpm"

http://rpm.pbone.net/index.php3/stat/4/idpl/15798779/dir/redhat_el_6/com/wxPython-2.8.12.0-1.el6.x86_64.rpm.html
(2) yum install wxPython-2.8.12.0-1.el6.x86_64.rpm

4.Ride
(1)Download "robotframework-ride-1.2.3.tar.gz"

 https://pypi.python.org/pypi/robotframework-ride/1.2.3
(2)tar zxf robotframework-ride-1.2.3.tar.gz
(3)cd robotframework-ride-1.2.3
(4)python setup.py install

5.Selenium2Library
(1)Download "robotframework-selenium2library-master.zip”

https://github.com/rtomac/robotframework-selenium2library
(2)unzip robotframework-selenium2library-master.zip
(3)cd robotframework-selenium2library-maste
(4)python setup.py install

三. Robot
1.Open RIDE: ride.py

2.New Project: "File" -> "New Project" ,click "OK".
    Name:Robot_Demo
    Type:Directory
ps:The difference between File and Directory is: We can write test case in File ,but Directory not.
Robot Framework test data is defined in tabular format, using either hypertext markup language (HTML), tab-separated values (TSV), plain text, or reStructuredText (reST) formats.

3.right click "Robot_Demo",choose "New Resource".click "OK".
    Name:resource
ps:We could put variables and higher-level user keywords in this file,then make testsuite invoked this resource file .

4.Import "selenium2library":Open "resource.txt",click "Library",input "Selenium2Library" in "Name".Click "OK".

5. right click "Robot_Demo",choose "New Suite" ,click "OK".
    Name:TestSuite1
    Type:File

6.Import "resource.txt":Open "TestSuite1",click "Resource",input "resource.txt" in "Path".Click "OK".

7.right click "TestSuite1" , choose "New Test Case",click "OK".
    Name:TestCase1

8.Edit test case "TestCase1":
    Open Browser    http://www.baidu.com    
    Maximize Browser Window        
    Input Text    id=kw    Robot
    Click Button    id=su    
    Close Browser        
ps: "Open Browser" is a selenium defined keyword, so it's marked with blue color.We could search all the keyword by "F5".
We could also set every test case with a "Tags": Edit->Settings->Tags.So that we could run test cases with special tags.

9.Run. Click Tab page "Run"->"Start".Then we could see the browser open with "http://www.baidu.com".

10.After it finished running,we could see the report by "Run"->"Report".
ps: If it failed,we could find the failed step screen shot in log: Run-> Log.

四 Comment:
1. Selenium Library
SeleniumLibrary is a Robot Framework test library that uses the popular Selenium web testing tool internally. It provides a powerful combination of simple test data syntax and support for different browsers. In addition to standard web testing, the library also supports testing Adobe Flex/Flash applications.

2.Selenium2Lib keyword:
(1)operate browser:
 --Open Browser
 --Maximize Browser Window
 --Go To
 --Reload Page
 --Close Window
 --Close Browser
 --Close All Browsers
(2)click
 --Click Button|locator
 --Click Element|locator
 --Click Image|locator
 --Click Link|locator
 --Double Click Element|locator
(3)locator:we could locate UI element with id/name/xpath/dom
 --identifier: Click Element|identifier=my_element (matches by @id or @name)
 --id         : Click Element|id=my_element (matches by @id)
 --name      : Click Element|name=my_element(matches by @name)
 --xpath     : Click Element|xpath=//div[@id='my_element']
 --link      : Click Element|link=my_link
 --css         : Click Element|css=div.my_class
 --tag         : Click Element|tag=div
ps:if the element is in a frame/iframe,we could locate it by : Select Frame| locator
(4)input
 --Input Password|locator| text
 --Input Text|locator|text
(5)press
 --Press Key|locator|Key
(6) verify:
 --Page Should (Not) Contain Button/Checkbox/Element/Image/Link/List/Radio Button/Textfield
 --Location should Be/Contain
 --Title Should Be
 --Current Frame Contains
 --Page Should (Not) Contain
 --Textfield Value Should Be
 --Element Should Be Disabled/Enabled/Visible/Contain
 --List Selection Should Be
 --List Should Have No Selections
 --Checkbox Should (Not) Be Selected
 --Radio Button Should Be Set To
 --Radio Button Should Not Be Selected
 --Table Cell/Column/Footer/Header/Row/ Should Contain
 --Xpath Should Match X Times
(7)wait
selenium2 will wait page load finished default,but we can also use keywords:
 --Wait For Condition| condition|timeout=None|error=None
 --Wait Until Page Contains|text|timeout=None|error=None
 --Wait Until Page Contains Element|locator|timeout


reference to robot user guide:http://robotframework.org/robotframework/#user-guide

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值