Browser | Selenium IDE | Selenium Remote Control | Selenium Core |
Firefox 3 | Record and playback tests | Start browser, run tests | Run tests |
Firefox 2 | Record and playback tests | Start browser, run tests | Run tests |
IE 7 | not supported | Start browser, run tests | Run tests |
Safari 3 | not supported | Start browser, run tests | Run tests |
Safari 2 | not supported | Start browser, run tests | Run tests |
Opera 9 | not supported | Start browser, run tests | Run tests |
Opera 8 | not supported | Start browser, run tests | Run tests |
Others | not supported | Partial support possible | Run tests |
Thursday, December 11, 2008
Browsers supported for different Selenium flavours
Tuesday, December 9, 2008
Why Selenium Server acts as Proxy for Selenium RC?
Monday, December 8, 2008
Commands that can be applied on HTML Elements in a page
Below are the commands that can be applied on HTML elements in a page.
Element | Commands can be Applied | |
TextBox | getValue(), getText(), isEditable(), isVisible(), type() | |
List Box | getSelectedId(),getSelectedIndex(), getSelectedLabel(),getSelectedValue(), getSelectOptions(), select() | |
Multi Select Element | getSelectedIds(),getSelectedIndexes(),getSelectedLabels(),getSelectedValues(),isSomethingSelected() | |
Radio Button | check(), click(), isChecked() | |
Check Box | Check(), click(),isChecked(), uncheck() | |
Button | click(), clickAndWait() | |
Link | click(), getAllLinks() | |
Text | getText(),getBodyText() | |
Tables and Cells | getTable() |
Selenium RC, The basic
Selenium RC consists of three main components, see below,
The HTTP proxy server, this component, once Selenium RC server started, it will ready to receive command from client.
The command interpreter, interpret command (HTTP GET/POST requests) and send to Selenium CORE.
The Selenium CORE
Installation
Following are topic about installation and prerequisite about Selenium RC.
Java Runtime (JRE)
You need to have Java Runtime because Selenium RC Server s written in Java. You can check you Java by open command line and type,
java -version
If you have Java installed on your machine, you will see,
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
If not, you have to download and install java. See details
Install Web Browser, If you don't have them
Before you go any further, please make sure that you have web browser you are going to use to test, for example, you will need to have Internet explorer and Mozilla Firefox installed on your machine in order to be able to test against them.
Getting Selenium up
Once have Java, web browser, next you are going to get Selenium RC. Step by step to get Selenium RC up and running,
Download Selenium RC you can save it wherever you want, for me, I saved it at D:Selenium
Extraction the zip, you will see following;
selenium-dotnet-client-driver-1.0-beta-1, .Net client driver
selenium-java-client-driver-1.0-beta-1, Java client driver
selenium-perl-client-driver-1.0-beta-1, Perl client driver
selenium-php-client-driver-1.0-beta-1, PHP client driver
selenium-python-client-driver-1.0-beta-1, Pytohn client driver
selenium-ruby-client-driver-1.0-beta-1, Ruby client driver
selenium-server-1.0-beta-1, Selenium RC server
Open command prompt and change directory to the path of Selenium RC server, For example if you save zip file uder D:\Selenuim, you path would be;
D:seleiumselenium-remote-control-1.0-beta-1selenium-server-1.0-beta-1
Under this path, you will see selenium-server.jar, this is our Selenium RC server.
Under the path, type java -jar selenium-server.jar. This will start Selenium RC server. You should see following at command line,
02:56:50.729 INFO - Java: Sun Microsystems Inc. 1.5.0_06-b05
02:56:50.729 INFO - OS: Windows XP 5.1 x86
02:56:50.729 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]
02:56:50.807 INFO - Version Jetty/5.1.x
02:56:50.807 INFO - Started HttpContext[/,/]
02:56:50.807 INFO - Started HttpContext[/selenium-server,/selenium-server]
02:56:50.807 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
02:56:50.823 INFO - Started SocketListener on 0.0.0.0:4444
02:56:50.823 INFO - Started org.mortbay.jetty.Server@2e7263
At this point, you have Selenium RC server up and running
Selenium RC, Interactive mode
If you want to write client driver at this point, you can start Selenium RC server with interactive mode. After server started, you can type command line by line and see how it work. To start server in interactive mode, type,
java -jar selenium-server.jar -interactive
Output should be,
03:08:03.495 INFO - Java: Sun Microsystems Inc. 1.5.0_06-b05
03:08:03.495 INFO - OS: Windows XP 5.1 x86
03:08:03.495 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]
03:08:03.589 INFO - Version Jetty/5.1.x
03:08:03.589 INFO - Started HttpContext[/,/]
03:08:03.589 INFO - Started HttpContext[/selenium-server,/selenium-server]
03:08:03.589 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
03:08:03.589 INFO - Started SocketListener on 0.0.0.0:4444
03:08:03.589 INFO - Started org.mortbay.jetty.Server@2e7263
Entering interactive mode... type Selenium commands here (e.g: cmd=open&1=http://www.yahoo.com)
You can try following command and observer the result,
cmd=getNewBrowserSession&1=*iexplore&2=http://www.google.com
You will see internet explorer pop up with Selenium RC page itself and lower frame. The lower frame will show the page under test. At the command line, you will see something like,
cmd=getNewBrowserSession&1=*iexplore&2=http://www.google.com
03:16:29.370 INFO - ---> Requesting
http://localhost:4444/selenium-server/driver?cmd=getNewBrowserSession&1=*iexplore&2= http://www.google.com
03:16:29.370 INFO - Command request: getNewBrowserSession[*iexplore, http://www.google.com] on session null
03:16:29.370 INFO - creating new remote session
03:16:29.370 INFO - Allocated session 3ef951a2ba6a481888cd3f8012b65194 for http://www.google.com, launching...
03:16:29.370 INFO - Modifying registry settings...
03:16:29.964 INFO - Launching Internet Explorer...
03:16:31.792 INFO - Got result: OK,3ef951a2ba6a481888cd3f8012b65194 on session 3ef951a2ba6a481888cd3f8012b65194
The last line tell you that command successfully execute with current test session (current session? yes, Selenium RC support multiple test session). Keep this in your current command line screen, you will need it to execute next command.
Let try to execute series of following command;
cmd=open&1=http://www.google.com/webhp&sessionId=3ef951a2ba6a481888cd3f8012b65194
cmd=type&1=q&2=helloworld&sessionId=3ef951a2ba6a481888cd3f8012b65194
cmd=click&1=btnG&sessionId=3ef951a2ba6a481888cd3f8012b65194
cmd=getTitle&sessionId=3ef951a2ba6a481888cd3f8012b65194
cmd=testComplete&sessionId=3ef951a2ba6a481888cd3f8012b65194
As you can see, with this command, you can automate internet explorer easily. But in real world, you will face complex testing. For example, will will need to verify correctness of processing of AUT. This will lead you to write programming language instead of typing command line-by-line.
Tuesday, December 2, 2008
How to Verify the Field MaxLength of an element in a page using Selenium IDE
Hi All,
We can verify the MaxLength of an element in a page with the help of CSS Locator using selenium IDE.
For example, verifying an length of an element using id and size of the element.
<tr>
<td>verifyElementPresent</td>
<td>css=input[id="username"][size="30"]</td>
<td></td>
</tr>
Thursday, November 27, 2008
Why Selenium scripts fail when run outside the web server for Selenium Core?
Hi All,
As we know selenium scripts will fail when we place our scripts outside the AUT (Application Under Test) web server for Selenium Core, this is due to the reason that Selenium core is built with DHTML / JavaScript. When we are using javaScript we should bound to Same Origin Policy of JavaScript.
What is Same Origin Policy?
Same origin Policy states that javaScript is only allowed to read / Modify the HTML content from the same origin as source i.e, javaScript can able to read / Modify the HTML only when the source and destination of the scripts are from same web server.
For Example:
Suppose a person is working on crutial page and some unsecured webpage simultaneously which are from different sources. If JavaScript is not bound to same Origin Policy, then the other user / Owner of unsecured web page can access / Modify the content of crutial web page. In order to avoid this JavaScript should be bound to Same Origin Policy.
But when we install Selenium IDE, this acts as a trusted FireFox extension and therefore we can violate the Same Origin Policy.
Wednesday, November 26, 2008
Handling Dropdown elements using Selenium IDE
Hi All,
Here is an example on how to handle Dropdown elements in selenium IDE.
Example:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Select From Dropdown</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Select From Dropdown</td></tr>
</thead><tbody>
<tr>
<td>store</td>
<td>58058</td>
<td>option1</td>
</tr>
<tr>
<td>store</td>
<td>30</td>
<td>index1</td>
</tr>
<tr>
<td>open</td>
<td>http://pages.ebay.com/sitemap.html</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>category0</td>
<td>label=Toys & Hobbies</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>category0</td>
<td>label1</td>
</tr>
<tr>
<td>assertSelectedIndex</td>
<td>category0</td>
<td>${index1}</td>
</tr>
<tr>
<td>assertSelectedLabel</td>
<td>category0</td>
<td>${label1}</td>
</tr>
<tr>
<td>select</td>
<td>category0</td>
<td>label=Computers & Networking</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>category0</td>
<td>label2</td>
</tr>
<tr>
<td>assertSelectedLabel</td>
<td>category0</td>
<td>${label2}</td>
</tr>
<tr>
<td>assertSelectedValue</td>
<td>category0</td>
<td>${option1}</td>
</tr>
</tbody></table>
</body>
</html>