不要為了工具而研究工具
要為業(yè)務(wù)而
就是這樣我都不記得了
以前是怎么弄的
有空再來~~~
知道rfs也是要pom映九,道行不夠淮悼,擱淺一陣子
先把手寫的python接口搞定~~~
*** Settings ***
Library Selenium2Library
Library AutoItLibrary
Library DatabaseLibrary
Library HttpLibrary.HTTP
pip install --upgrade robotframework-httplibrary
向某IP和端口是9000發(fā)送一個(gè)請求,然后查看返回的狀態(tài)腔长,如果返回的狀態(tài)有302秆吵,出現(xiàn)了重定向样傍,請用Follow Response這個(gè)API繼續(xù)调煎,如果是200镜遣,那么就直接拿來使用。
Step3
Comment Start Step3
Create Http Context host=xx.xx.xx.xxx:9000 scheme=http
Get /xx/xxx/xxxx
${RESPONSE_STATUS}= Get Response Status
Should Start With ${RESPONSE_STATUS} 200
Comment End Step3
pip install pyodbc
suite1
*** Settings ***
Library Selenium2Library
Resource key11.txt
Library AutoItLibrary
Library HttpLibrary.HTTP
*** Test Cases ***
t1
[Documentation] destination:test1
...
...
... author:dido
打開baidu http://www.baidu.com
搜索內(nèi)容 didododododo
[Teardown] run keyword if test failed close browser # teardown
retunkeyword
${a} set variable 4
$士袄 set variable 0
run keyword if ${a}>=1 log 1
... ELSE IF $悲关<=4 log 2 ElSE log
... 3
forxun
: FOR ${i} IN RANGE 3
\ log ${i}
\ 打開baidu http://www.badu.com
\ sleep 1
\ 關(guān)閉瀏覽器
evalue
${a} evaluate os.system(r'dir>d:\\text.txt') os
autoit
Run sublimetext3.exe
winwaitactive 記事本
send This is a test{1}^s
winwaitactive 另存為 *.txt
send {del}
odb
connect to database using custom params pyodbc "Driver={Mysql};Server=127.0.0.1;Database=test;UID='admin';PWD='test'"
${a} query select * from test.t1
log ${a}
disconnect from database
case3duocan
duokey1 111 222 333
Step3
Comment Start Step3
Create Http Context host=xx.xx.xx.xxx:9000 scheme=http
Get /xx/xxx/xxxx
${RESPONSE_STATUS}= Get Response Status
Should Start With ${RESPONSE_STATUS} 200
Comment End Step3
suite2
*** Settings ***
Library Selenium2Library
Resource key11.txt
*** Test Cases ***
testlog
log dido
mnav
openbrowser http://www.baidu.com/
set browser implicit wait 10
${title} set variable gettitle
inputtext id=kw hiloo dido
click element id=su
log ${title}
closebrowser
key1
${result} create list 糯米 新聞 hao123 地圖 視頻
... 貼吧 學(xué)術(shù)
打開baidu
: FOR ${a} IN RANGE 6
\ ${title} 打開鏈接 ${a}
\ log ${title}
\ log ${result[${a}]}
\ should contain ${title} ${result[${a}]}
close all browsers
kkk
${result} Create List 糯米 新聞 hao123 地圖 視頻
... 貼吧
打開baidu
: FOR ${a} IN RANGE 6
\ ${title} 打開鏈接 ${a}
\ log ${title}
\ log ${result[${a}]}
\ Should Contain ${title} ${result[${a}]}
close all browsers
testkey
打開baidu http://www.baidu.com
搜索內(nèi)容 didododododo
fal
runkeywordif
should be true
should not be true
:for
exit for loop
exit for if
keyword
*** Settings ***
Library Selenium2Library
*** Keywords ***
打開baidu
[Arguments] ${url}
open browser ${url}
set browser implicit wait 10
打開鏈接
[Arguments] ${i}
${s} get webelements css=.mnav
click element ${s[${i}]}
sleep 3
${title} get title
log ${title}
go back
[Return] ${title}
登陸
搜索內(nèi)容
[Arguments] ${stext}
inputtext id=kw ${stext}
關(guān)閉瀏覽器
close browser
duokey
[Arguments] ${arg1} ${arg3} ${arg4} ${arg2}=222
duokey1
[Arguments] ${arg4} @{arg2} # at is a list and should be last
Fail ${arg4}===${arg2}
p.s.
越是靠近上層的部分谎僻,腳本越貼近自然語言,或者說很像我們的測試案例寓辱;越靠近下層的部分戈稿,越是接近頁面元素的代碼級(jí)部分。這樣以后如果發(fā)生維護(hù)的時(shí)候讶舰,根據(jù)需要維護(hù)的內(nèi)容,只需要在很少的地方進(jìn)行調(diào)整即可需了。比如一個(gè)元素的id變了跳昼,那我只要在elements里面更新就行了。比如測試的流程調(diào)整了肋乍,以前是ABC的頁面順序鹅颊,現(xiàn)在是ACB的頁面順序,那么只要在testflow層進(jìn)行調(diào)整即可墓造。
那么回到我們的標(biāo)題堪伍,流程與數(shù)據(jù)分離,實(shí)際上目前我們的流程都集中在testflow以及下面的部分觅闽,而數(shù)據(jù)一般都是在案例層去給流程層傳遞帝雇,這就是我們的流程與數(shù)據(jù)分離了。當(dāng)然蛉拙,我們還可以再進(jìn)一步的分離尸闸,把數(shù)據(jù)放到外面,脫離我們的案例孕锄,在運(yùn)行的時(shí)候才傳遞進(jìn)行吮廉,也是可以實(shí)現(xiàn)的。
名稱 | 瀏覽器 |
---|---|
firefox | FireFox |
ff | FireFox |
internetexplorer | Internet Explorer |
ie | Internet Explorer |
googlechrome | Google Chrome |
gc | Google Chrome |
chrome | Google Chrome |
opera | Opera |
phantomjs | PhantomJS |
htmlunit | HTMLUnit |
htmlunitwithjs | HTMLUnit with Javascipt support |
http://ratlsun.iteye.com/blog/1869379
名稱 | 瀏覽器 |
---|---|
firefox | FireFox |
ff | FireFox |
internetexplorer | Internet Explorer |
ie | Internet Explorer |
googlechrome | Google Chrome |
gc | Google Chrome |
chrome | Google Chrome |
opera | Opera |
phantomjs | PhantomJS |
htmlunit | HTMLUnit |
htmlunitwithjs | HTMLUnit with Javascipt support |