Selenium Robot Framework installation on Python
Step 1: Install supported Python
version. (I prefer Python 2.6.6)
-http://www.python.org/download/releases/2.6.6/
Step 3: Add Python installation directory and scripts directory (example -C:\Python26; C:\Python26\Scripts) to path variable. That will allow you direct execution.
Step 4: Execute command in command prompt “pybot --version”. If you have done all correctly up to now, you will see the robot framework and python versions.
Step 5: In addition, you may install ‘setuptools’ or ‘distribute’. That will help you to install PIP.
- Install Setup tools: Distribute was merged back into Setuptools 0.7. download 'ez_setup.py' from https://bitbucket.org/pypa/setuptools/downloads and install using “python ez_setup.py” command.
- Install Distribute: Distribute is a collection of enhancements to the Python standard library module. Download distribute_setup.py from https://pypi.python.org/pypi/distribute/0.6.27 and install using “python distribute_setup.py” command.
Once installation is complete,
you will find an easy_install.exe program in your
Python Scripts subdirectory.
Step 6: Install PIP using
“easy_install.exe pip” command.
Step 7: Install selenium2library
using “pip install robotframework-selenium2library” command.
Optional : Install suitable selenium editor, which is convenient option to customize your script. I prefer RIDE or Ninja IDE.
Install Robot-IDE (RIDE) - RIDE
is an editor for Robot Framework
- Step1: install wxPython2.8 using installer (http://wxpython.org/download.php#stable>) - You need to install wxPython 2.8 toolkit with unicode support to run RIDE
- Step2: install robot framework ide from installer (https://code.google.com/p/robotframework-ride/downloads/list)
- Step3: Execute command “python ride.py” to invoke the IDE
TIP 1 : Install firefox addon – “element locator for web driver”. That will help you to find locators (xpaths). Later, you will realize what is a locator and its usages. For now, just install it.
Tip 2: Install firefox addon – “firepath “. This will helps
you to customize xpaths.
TIP 3 : If you suppose to run your selenium test in various browsers you need to install relevant web driver. Just download the correct web driver and place it inside the C:\Python26\Scripts folder. (example – download Chrome web driver from https://code.google.com/p/chromedriver/downloads/list)
Congrats! Now you are ready to write your first selenium script. Here we go!
What are we going to do is,
·
Open firefox browser.
· Load google site.
· Load google site.
· Search the word given by variable.
· Validate the page title of the search result page.
There are 5 easy steps to do it.
Step 1: Create a folder named “helloworld” in your python
installation directory.
Step 2: Create two sub-folders “resource” and “script” inside the “helloworld” folder.
Is there any other libraries?
Yes. There are several selenium libraries display here - http://robotframework.org/#test-libraries You can import relevant library and use it’s keywords.
'objectmap.py' include locators of the search buttons and input field. you can find these locators using the firefox addon – “element locator for web driver”.
Step 4: Now, the most important step of the flow. Create a file ‘helloworld.txt’ inside the script folder with below content.
I think you can easily understand this script. You can find the keywords ‘Input Text’, ‘Click Button’, and ‘Title Should Be’ at the selenium2library. ‘Wait Until Keyword Succeeds’ is a keyword from BuiltIn library.
That’s it! Now you know all the basics to develop any complex script.
On day-3, I suppose to discuss about some common selenium libraries and their behaviors, working with windows dialog box, working with oracle database using python database library, logs/reporting and some more complex mechanisms. Bye for now and see you soon!