|
Demo
Simple Robot Framework and SeleniumLibrary demo
Featured
IntroductionRobot Framework is a generic test automation framework and SeleniumLibrary is one of the many test libraries that can be used with it. In addition to showing how the SeleniumLibrary works, this demo introduces the basic Robot Framework test data syntax, how tests are executed, and how logs and reports look like. The SeleniumLibrary architecture gives an high level overview of the different components. PreconditionsTo be able to execute the demo, both Robot Framework and SeleniumLibrary need to be installed. Notice that in addition to Python required by Robot Framework, you need to have Java 1.5 or newer to run Selenium Server. If you do not have time or interest to install everything, you can still take a look at the test cases and generated logs and reports online. Downloading and executing the demoThe demo is available on the download page. Latest version is robotframework-seleniumlibrary-demo-20110131.zip. It requires Robot Framework 2.5 and running the included Flex demo requires SeleniumLibrary 2.6. The earlier robotframework-seleniumlibrary-demo-20100428.zip works also with Robot Framework 2.1.x versions. After downloading and unzipping the package, you should have all the files in a directory robotframework-seleniumlibrary-demo. The rundemo.py script is used for executing tests, demoapp directory contains two versions of the system under test, and actual test cases are in the login_tests directory. To run the test cases execute the following command in the extracted directory: python rundemo.py login_tests This should work in most environments if you have Firefox installed. See chapter executing tests for more information about running the tests with different browsers. Systems under testThe system under test in the demo is a very simple application that only has login functionality. There are two versions of this application, one implemented as HTML pages and the other an Adobe Flex application. Both of these should run without special preconditions, but see these instructions if you want to test your own Flex application. The different versions of the application are shown in the below screenshots. The correct user name and password combination to both applications is demo/mode and using them will show you a welcome page. Otherwise an error page or dialog is shown.
The demo applications are normally started and stopped automatically by the rundemo.py script when tests are executed. The same script can also be used to start and stop the applications so that those can be investigated manually: python rundemo.py demoapp start
python rundemo.py demoapp stopAfter starting the demo application, the HTML version can be accessed from URL http://localhost:7272/html and the Flex version from http://localhost:7272/flex. The application source codes are located in the demoapp/html and demoapp/flex directories inside the extracted zip file. Selenium ServerRunning tests using the SeleniumLibrary requires Selenium Server to be running. A version of the server is bundled with the library, and starting and stopping it is handled by the rundemo.py script automatically when it is used for executing tests. It is possible to also start/stop the server separately: python rundemo.py selenium start
python rundemo.py selenium stopTest casesThe test cases distributed with the demo are in the login_tests directory and visible also online. They are in plain text format (Robot Framework support also HTML and TSV formats), and can be edited using any text editor. There exists also a special Robot Framework test data editor RIDE. The simplest test case file is valid_login.txt, which contains only one test case Valid Login. This test case has a simple workflow, created using keywords, that starts from opening the browser and ends with verifying that the welcome page has been opened. The other test case file, invalid_login.txt, has several test cases that verify different invalid login scenarios such as invalid or empty user name. These tests are data-driven in their nature and each of them only has one keyword that encapsulates the needed workflow. Both of these test case files use domain specific high-level keywords, such as Open Browser To Login Page. These keywords use lower level keywords internally, such as Title Should Be and Open Browser. In this demo the higher level keywords are created in technology specific resource files html_resource.txt and flex_resource.txt. In addition, there is a common resource file common_resource.txt, which defines some variables, for example to determine which version of the application to test against. The lowest level keywords always come from test libraries, in this case from the SeleniumLibrary that provides generic keywords for web testing. Executing test casesUsing rundemo.pyThe easiest way to run the test cases is using the already mentioned rundemo.py script, which automatically starts and stops both the system under test and the Selenium Server. Tests are executed by giving a path to tests to run as an argument to rundemo.py. It is possible to run either a single test case file by giving a path to that file, or all test case files in a directory by giving a path to the directory: python rundemo.py login_tests/valid_login.txt
python rundemo.py login_testsWhen tests are executed, rundemo.py passes arguments it gets directly to the pybot command that is normally used for running Robot Framework test cases. The pybot command supports various command line options (run pybot --help for a full list), and when they are needed they must be given before the test data path as in these examples: python rundemo.py --name New_name login_tests/
python rundemo.py --outputdir results --loglevel DEBUG login_tests/Using different browsersBy default tests are executed using the Firefox browser. The browser to use is defined as a ${BROWSER} variable in the common_resource.txt file, and it can be easily overridden from the command line: python rundemo.py --variable BROWSER:IE login_tests/
python rundemo.py --variable BROWSER:GoogleChrome login_tests/What browsers are supported and how to use them is explained in the documentation of the Open Browser keyword. Selecting application to testBy default, the test cases are run against the HTML version of the test application. This can be changed by overriding ${SUT} variable from the command line: python rundemo.py --variable SUT:flex login_tests/ Slowing down executing speedTypically the tests run so fast (except for opening the browser) that it is impossible to see what is happening. The execution speed can be slowed down by overriding the ${DELAY} variable: python rundemo.py --variable DELAY:0.5 login_tests/ Running tests using pybotIt is possible to run the tests also using the normal pybot start-up script, but that requires that the demo application and the Selenium Server are started before. This might be a good idea if starting the demo application and Selenium Server takes a lot of time and you want to run tests multiple times. This example shows a possible workflow: python rundemo.py selenium start
python rundemo.py demoapp start
pybot --variable BROWSER:Firefox --outputdir firefox login_tests
pybot --variable BROWSER:IE --outputdir ie login_tests
python rundemo.py demoapp stop
python rundemo.py selenium stopViewing logs and reportsAfter tests have been executed, Robot Framework creates a detailed log file listing all the executed keywords with their possible log messages. Another important output is the test report that has a higher level summary of the test execution. By default these files are created into the directory where tests are executed from, and exact locations are shown on the console after the execution. Example outputs generated when these tests are run are available online: Where to find more informationRobot Framework documentation is available on the project pages at http://robotframework.org. If you are new to the framework you may want to start from the introduction slides and then look at the Quick Start Guide, which also acts as another executable demo. All the Robot Framework features are documented in the comprehensive User Guide. More information about the SeleniumLibrary is available here in the library's wiki. Most importantly the library documentation documents all the available keywords. |
I get the following error:
C:\Python25\Lib\site-packages>python rundemo.py login_tests Traceback (most recent call last):
ImportError?: No module named SeleniumC:\Python25\Lib\site-packages>
hqhash, are you sure you have installed SeleniumLibrary?? Did you get any errors while doing it?
I get the following error:
C:\Python26\Lib\site-packages\SeleniumLibrary?\robotframework-seleniumlibrary-dem o>python rundemo.py login_tests Traceback (most recent call last):
<module> ImportError?: No module named robot.errorsicocitto, it seems that you don't have Robot Framework itself installed or the installation has failed somehow. You can find installation instructions from http://robotframework.org
you are right !! i forget to install roboframework. thank!
Installed roboframework....I get the following error:
C:\Python26\Lib\site-packages\SeleniumLibrary?\robotframework-seleniumlibrary-dem o>python rundemo.py login_tests 'pybot' is not recognized as an internal or external command, operable program or batch file.
icocitto, did you set PATH on Windows so that you can execute 'pybot' from the command line? You should be able to run, for example, 'pybot --version'. You can find detailed installation instructions from the User Guide: http://code.google.com/p/robotframework/wiki/UserGuide
Thanks a lot !!!! pekka.klarck ....I set up the PATH <directory Python 2.6>\Scripts\ and RESTART my windows, and works perfectly.
Guys,
- Palani.
If you get the error message:
Traceback (most recent call last):
OSError: 2? No such file or directoryThen you have to write: pybot-2.6 rundemo.py login_tests instead of: python rundemo.py login_tests
alexander.vanderberg, do you mean python-2.6. Did this happen on OSX?
pekka: yes, it was on Mac OSX Snow Leopard.
python2.6 rundemo.py login_tests shows the error message above,
pybot-2.6 rundemo.py login_tests works fine.
alexander.vanderberg, pybot is the start-up script that runs Robot Framework on Python. I'm confused by pybot-2.6 because no such script is distributed with the framework. Anyway, great that you got the demo working somehow.
i downloaded and installed all .. now i have one doubt .. where i need to run-------- python rundemo.py login_tests ? this command in dos or python..
@santu.qtp: Yes, run python rundemo.py login_tests in the command prompt on the directory that you extracted.
getting error as "error? Timed out after 80000ms" when giving click and wait command.
pls answer this qs .. i need sm update for tom's stand up meeting
When I am running the command : "python rundemo.py login_tests"
I get the following error msg:
The Selenium is successfully installed at "D:\Python27\Lib\site-packages\SeleniumLibrary?".
Do you have any suggestion on this ? I am sure SeleniumLibrary? is installed but I think currently it needs some configuration with python lib path ??? to let the python know where to find the location of the SeleniumLibrary?.
Please help me with this.
Iam getting this error.
'pybot' is not recognized as internal or external command, Operable program or batch file.
try pybot.bat and ensure PythonPATH\Scripts has been added to PATH environment.
Query related to Logs and Reports - 1. By default these files are created into the directory where tests are executed from. How can I change the directory path to get reports on specified location. ?
2. Can I save my reports for each run at some new location or with some timestamp?
Thanks in advance.
I've just downloaded robotframework-seleniumlibrary-2.8.1 onto my laptop running Ubuntu 10.04 and made my first steps by executing the demo. Everything works. Wonderful! Thank you to all.
Hi,
I am new to robot framework and I need some help with Selenium Library. I have installed selenium library in path C:\Python27\Lib\site-packages\SeleniumLibrary? using windows installer and trying to run the demo app. My demo app is extracted in location C:\RobotFramework?\robotframework-seleniumlibrary-demo-20110131\robotframework-seleniumlibrary-demo.
When I try to start selenium server, I am getting below error message
C:\RobotFramework?\robotframework-seleniumlibrary-demo-20110131\robotframework-se leniumlibrary-demo>python rundemo.py selenium start Traceback (most recent call last):
start_selenium_server WindowsError?: 2? The system cannot find the file specifiedNot able to figure out what is wrong.Please help
Bharath
Never mind, fixed the issue with installation of JRE
hi i have installed robot framework and selinium libraries on windows. but i did nt get how to write a sample testcase even after seeing the examples.can u be more specific that how to write a test case basing one scenario.
thanks in advance
and if iam running the sample file .. iam getting the follwing error on my command prompt as
D:\softwares\robot framework>dir
04/19/2012 03:55 PM <DIR> . 04/19/2012 03:55 PM <DIR> .. 04/18/2012 12:46 PM 3,064,610 curl-7.25.0.tar.gz 04/19/2012 01:16 PM <DIR> LoginTest? 04/19/2012 01:16 PM 1,498 LoginTest?.zip 04/19/2012 10:48 AM 69 New Text Document.txt 03/29/2012 02:39 PM 15,970,304 python-2.7.2.msi 04/18/2012 03:26 PM 15,923,120 robotframework-2.7.1.jar 04/19/2012 10:24 AM 716,377 robotframework-2.7.1.win32.exe 04/19/2012 01:12 PM 26,583,129 robotframework-seleniumlibrary-2.8.1.win3 2.exe 04/19/2012 11:22 AM <DIR> robotframework-userguide-2.7.1 03/27/2012 02:47 PM 1,381,744 robotframework-userguide-2.7.1.zip 04/19/2012 03:54 PM 398 simple.txt
D:\softwares\robot framework>java -jar robotframework-2.7.1.jar simple.txt ERROR Error in file 'D:\softwares\robot framework\simple.txt' in table 'Sett ings': Importing test library 'SeleniumLibrary?' failed: ImportError?: No module n amed SeleniumLibrary? Traceback (most recent call last):
PYTHONPATH: CLASSPATH:Simple
Login Should Succeed When the Correct Username and Password are En... | FAIL | No keyword with name 'Start Selenium Server' found.
Simple | FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1 failed
hi , this is the first problem i am facing
C:\Python27>pybot myfristtext.txt 'pybot' is not recognized as an internal or external command, operable program or batch file.
and the second problem is
C:\Python27>java -jar robotframework-2.7.1.jar myfristtext.txt Exception in thread "main" Traceback (most recent call last):
18, in <module> ", line 17, in <module> SyntaxError?: no viable alternative at input '""'nice