RIDE上:
F5 帮助文档,那些库有哪些关键字可用
ctrl+shift+空格 在输入框按下后,快速补全关键字
关键字举例:
Page Should Contain Image xpath=//img[@src="http://***.jpg"] --》使用了xpath找节点
Execute Javascript${CURDIR}/test.js --》页面上执行js来模拟用户行为
在线文档:
robot丰富的开源库:http://robotframework.org/#test-libraries
Selenium2Library的帮助文档:http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html
yum install xorg-x11-server-Xvfb.i386 --虚拟界面
python get-pip.py
pip install xvfbwrapper
pip install robotframework
pip install robotframework-selenium2library==1.4.1 可以使用pip install -U 升级
pip install robotframework-sshlibrary
yum install firefox.i386
发现selenium最新的 selenium 2.40 只支持Firefox 27的。类似这种问题也要注意下!
python-2.7.6.msi
setuptools-0.6c11.win32-py2.7.exe --》 装easy_install
wxPython2.8-win32-unicode-2.8.12.1-py27.exe
robotframework-2.8.1.win32.exe
easy_install robotframework-selenium2library
robotframework-ride-1.2.win32.exe
python -c "from robotide import main; main()"
记得在环境变量加上C:\Python27 C:\Python27\Lib C:\Python27\Scripts
使用selenium遇到的问题汇总:
1、使用selenium时如何针对不同的ua进行测试,拿firefox举例(自己研究的,网上找不到这个,估计只能找到chrome的):
编写一个关键字openurl_ua, 参数为${ua}:
${ffprofile}= Evaluate sys.modules['selenium.webdriver.firefox.firefox_profile'].FirefoxProfile()sys, selenium.webdriver.firefox.firefox_profile
Call Method ${ffprofile} set_preferencegeneral.useragent.override${ua}
Create WebDriver Firefox firefox_profile=${ffprofile}
2、有时候会遇到“Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open”然后测试失败,全部红色
原因:
1) firefox被kill掉或者自动退出了;
2) selenium2使用上本身遗留的一个问题,如果偶然遇到这个问题,可以多给两次机会跑用例,一般运气没那么差会连续两三次都遇到这种偶现情况
3、类似“WebDriverException: Message: u'elem is null' ; Stacktrace”这种提示google不到答案的,问题就处在自己写的测试案例身上
4、pybot layout/css/test.txt 不执行最顶层suite的setup,应该要加参数才行,目前还不知道怎么搞。
5、关键字不要乱起名字以免误解,要求清晰直接,这才是关键字的精髓