Você está na página 1de 14

The Natural ari

The Natural ta
The Natural ver
The Natural tre

Selenium installation Guide


Selenium Remote Control

You can download the Selenium Remote Control from the website given below.

http://www.openqa.org/selenium-rc/download.action

Latest version: Version 0.9.2

Steps to be followed

1. Unzip the folder to any specified location you want.

2. Go to the command prompt.

3. Type the command containing the path of the selenium server like

cd C:\seleniumRC\selenium-remote-control-0.9.2-dist\selenium- remote-
control-0.9.2\selenium-server-0.9.2
Press enter. (Give the path in which you have kept your selenium)

1
4. Then type java –jar selenium-server.jar –interactive
Press enter
This will start the selenium server with allowing the user to write commands
like….
Entering interactive mode... type Selenium commands here (e.g.:
cmd=open&1=http://www.yahoo.com)

We can also give directly by specifying all commands in one go, instead of giving
it separately.
C:\>java -jar C:\seleniumRC\selenium-remote-control-0.9.2-
dist\selenium-remote-control-0.9.2\selenium-server-0.9.2\selenium-
server.jar –interactive

2
5. Now you are ready to type your command. Like which I have given below
If IE then type this command on the selenium server screen (command prompt)

If you want to use Firefox, try this:


cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
If all goes well, you should see a new browser window starting with the browser
of your choice. Back in the Selenium Server command window, you should see
the following message:
Got result: OK, 794468 on session 794468

3
NOTE: Each session will give different session ID and you have to replace the
session ID with your session ID.
This command will open the selenium test runner with the corresponding session
ID generated for that session.
The following window shows Selenium Test Runner.

4
If you want to do more then type the following commands to perform a google
search
cmd=open&1=http://www.google.com/webhp&sessionId=794468

When thie following command finishes, your browser window should


reveal google.com in the lower frame.

5
Then Type the below command for typing a search string in the search text box.

cmd=type&1=q&2=hello world&sessionId=794468

6
Now you can see that the “hello world” is displayed on the lower frame of the
browser , which is shown below.

7
In order to perform the search,we need to click the search
Buttom,for that type the following command.
cmd=click&1=btnG&sessionId=794468

The corresponding result is obtained in the lower frame of the browser.

The window is shown below.

8
In order to get the name of the browser,just type the following
command on the command prompt.
cmd=getTitle&sessionId=794468

9
At any point of time, to shut down the server type control+c

Important Points:

 Make sure you have java installed in your system version 1.5 or above.
 If you get any port related error then try changing the port number.
E.g. port<new port number>
java -jar selenium-server.jar -port
<a_free_port_number_like_4445>

 If you get an error saying something like this,

HTTP ERROR: 400


Could not proxy http://www.google.com/webhp
java.net.UnknownHostException: www.google.com
RequestURI=/webhp
Powered by Jetty://
Then change the proxy settings or try without proxy.

For running Automation Scripts steps are given below.


Pre-requisite
1. Selenium RC
2. Jdk 1.5 or above
3. Junit or TestNG (I am using junit)
4. Set Class Path: Add Java class path, selenium class path and junit class path
10
Go to My Computer properties->advanced->Environment Variables-> System Variables

You will be having a class path variable, just need to add the new jar files to it.
Steps
1. Create a java file for running the simple Google search. You can record a Google test
through Selenium IDE and then export it to java.
Name the file as GoogleTest.java and save in any location.
2. Compile the java code through command prompt.
Command for complication
c:javapath/javac filename.java
Make sure that you are in the path where you have saved the java file

11
3. Then in another command prompt start selenium server using the command given in
step 3 to 4 in the steps to be followed.
Java –jar selenium-server.jar –interactive
4. Run the java file using the command java filename

This will start the selenium core and will perform the Google search (as per the
program is intended to do)

Selenium IDE

This is used for record and play back.


The installation is very simple.
You can download the Selenium IDE from the website given below.

http://www.openqa.org/selenium-ide/download.action
12
Latest version: Version 0.8.7

Then go to the firefox


Toolbar->extensions click on that, a window will open just drag and drop the selenium
IDE to that window.

From that you can click on the selenium IDE, the window will appear on the screen.
Which is shown below.

13
14