Você está na página 1de 2

o, how do we create and run Selenium tests ? Check out the following.

You need:
Knoweldge in HTML will be extremely useful.
Latest Java Runtime Environment (JRE). Get it from Oracle/Sun and install it. Te
st if it's installed correctly by running: java -version from the command line.
Firefox browser. Download it from Mozilla and install
Firebug Addon for Firefox browser. This Addon is very useful when locating eleme
nts and their attributes. Get it from getfirebug.com. Install the Addon. You sho
uld see 'Firebug' in the Firefox Tools menu option.
Firexpath Addon for Firefox browser. This works with Firebug and is available as
another tab 'xpath' in the firebug window. Sometimes, on dynamic web applicatio
ns, attributes (id, name, etc) of the elements of a web page are dynamically gen
erated too. This means everytime the page is generated, the attribute will chang
e. Then, we have to uniquely identify the element in reference to a label or tex
t surrounding it. So, get it from here
Selenium RC. Selenium RC is the core engine that is used to execute the tests. D
ownload it from seleniumhq.org/download/
Selenium IDE. Selenium IDE is a Firefox Plug-in (Addon) used to record / create
tests from the UI. Download it from seleniumhq.org/download/. After installation
, you should see 'Selenium IDE' in the Firefox Tools menu option.
Download psycopg2 if you need your scripts to talk to Postgresql via python. Dow
nload the psycopg2 windows installer for python version 2.6 from here: http://ww
w.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.2.wi...
Steps to setup Selenium RC on Windows:
Extract the downloaded Selenium RC package (Eg. selenium-remote-control-1.0.3.zi
p) into your local folder. You should see many folder as shown below
C:\selenium-remote-control>dir
Volume in drive C has no label.
Volume Serial Number is 8496-7482
Directory of C:\selenium-remote-control
08/02/2010 11:35 AM <DIR> .
08/02/2010 11:35 AM <DIR> ..
08/02/2010 11:34 AM 224 README.txt
08/02/2010 11:34 AM <DIR> selenium-dotnet-client-driver-1.0.1
08/02/2010 11:34 AM <DIR> selenium-java-client-driver-1.0.1
08/02/2010 11:34 AM <DIR> selenium-perl-client-driver-1.0.1
08/02/2010 11:34 AM <DIR> selenium-php-client-driver-1.0.1
08/03/2010 02:54 PM <DIR> selenium-python-client-driver-1.0.1
08/02/2010 11:34 AM <DIR> selenium-ruby-client-driver-1.0.1
08/02/2010 11:35 AM <DIR> selenium-server-1.0.3
You can now start the Selenium RC server
C:\selenium-remote-control>java -jar C:\selenium-remote-control\selenium-server-
1.0.3\selenium-server.jar
The above is run with bare minimum options. If you need (it's a good practice),
redirect the following output to a file by using the '-log <filename>' option.
16:06:12.999 INFO - Java: Sun Microsystems Inc. 17.0-b16
16:06:12.999 INFO - OS: Windows XP 5.1 x86
16:06:13.049 INFO - v2.0 [a2], with Core v2.0 [a2]
16:06:13.429 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
16:06:13.439 INFO - Version Jetty/5.1.x
16:06:13.439 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
16:06:13.450 INFO - Started HttpContext[/selenium-server,/selenium-server]
16:06:13.450 INFO - Started HttpContext[/,/]
16:06:13.640 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@194ca6
c
16:06:13.640 INFO - Started HttpContext[/wd,/wd]
16:06:13.670 INFO - Started SocketListener on 0.0.0.0:4444
16:06:13.680 INFO - Started org.openqa.jetty.jetty.Server@c40c80
Now start your firefox browser
Launch Tools -> Selenium IDE. Notice a small window opens up. Selenium IDE start
s in recording mode by default.
Type in www.google.com in your browser, enter a search term and hit search butto
n.
Notice that all these actions and the values entered are recorded in the Seleniu
m IDE window
You can now save the script and click the Green button to replay the script
Note that by default Selenium stores your tests in plain HTML tables.
At this point you actually don't need Selenium RC to run the test you recorded u
sing Selenium IDE. If it is a static page and does not involve any dynamic web c
ontent generation, this should suffice. But in the real world testing of web app
lications, this is not so. You need to use programming capabilities to use dynam
ic input data from a data source (could be a csv file, config file or even datab
ase).
So using a programming language becomes a necessity to make our test automation
meaningful and worthwhile. You can use python, php, ruby, perl or java with Sele
nium RC to do this. I've used python and it's pretty good and easy to learn too.
I will write on using python with Selenium in another blog post.
Hope this was helpful. Here are some references that will be useful to learn how
Selenium works.
Selenium Reference
XPATH Examples

Você também pode gostar