Issue #14: use robotframework for selenium tests!?
Reported by: | domruf |
State: | resolved |
Created on: | 2014-07-29 22:00 |
Updated on: | 2014-09-08 16:52 |
Description
I'm new to robotframework but I think it is a really good way to create selenium test cases. And they are really easy to read. Here is an example I just created.
*** Settings *** Library Selenium2Library *** Test Cases *** Login Open Browser http://localhost:5000/_admin/login chrome Input Text css=#username test_admin Input Text css=#password test12 Click Element css=#sign_in Page Should Contain Element css=.logout Fork Go to http://localhost:5000/vcs_test_hg Mouse Over link=Options Click Link /vcs_test_hg/fork Submit Form
Even if you don't know anything about robotframework it is possible to understand what this test does. I think it is better then writing the tests in python. Since my example is just a quick hack here are two videos that better demonstrate the potential of robotframework http://vimeo.com/93124154 http://vimeo.com/94638895
Before I start creating real test cases I though I ask you if you think this is a good way to do it.
Attachments
Comments
Comment by Mads Kiilerich, on 2014-07-29 23:45
See also https://bitbucket.org/conservancy/kallithea/pull-request/16/ by @troter . It seems like there are two good alternatives.
Comment by domruf, on 2014-07-30 08:57
here is the test from kallithea/tests/integration/test_login.py written for robotframwork.
to run it simple
pip install robotframework-selenium2library
put the following in a text file like login.robot
*** Settings *** Library Selenium2Library Suite Teardown Close All Browsers *** Variables *** ${BASE URL} http://localhost:5000 ${LOGIN URL} ${BASE URL}/_admin/login ${LOGOUT URL} ${BASE URL}/_admin/logout *** Test Cases *** Test Start Page Open Browser ${BASE URL} phantomjs Page Should Contain Element css=#sign_in Page Should Contain Not logged in Test Login Admin Go To ${LOGIN URL} Input Text css=#username test_admin Input Text css=#password test12 Click Element css=#sign_in Page Should Contain Kallithea Admin Test Logout Admin Go To ${LOGOUT URL} Page Should Contain Not logged in
and then start
pybot login.robot
phantomjs has to be in the path and a kallithea instance has to run on port 5000 of course :-)
Comment by domruf, on 2014-07-30 09:03
You can also start hg or git commands with robotframework or setup and tear down kallithea instances.
I think I will create a more sophisticated example to show some of the advantages of robotframework when I find some time on the weekend.
Comment by Mads Kiilerich, on 2014-07-30 16:10
Thanks, this seems very promising. I hope @troter will share his opinion. He went more into actual intregration his approach into the test framework.
My main concern is how to debug failures and the cases where it doesn't containt he expected string. I would love to be able to stop the automation at some point and investigate it with my browser. That is currently very hard with the tests we have.
Comment by domruf, on 2014-07-30 19:22
Robotframework creates html and xml reports incl. screenshots in case of an error of all the test cases. You can also create screenshots in passed tests manually if you'd like. And I think you can also stop the test execution if an error occurs and leave the browser open. (but I haven't tried that yet) But then you have to use chrome or firefox instead of phantomjs of course :-)
Comment by Mads Kiilerich, on 2014-09-08 16:52
This is now better tracked on PR 33