Selenium Remote Control

13
Selenium Remote Control Information and Installation Procedure Automation Testing: Introduction Software testing using an automatic test program will generally avoid the errors that humans make when they get tired after multiple repetitions. The test program won't skip any tests by mistake. The test program can also record the results of the test accurately. The results can be automatically fed into a database that may provide useful statistics on how well the software development process is going. On the other hand, software that is tested manually will be tested with a randomness that helps find bugs in more varied situations. Since a software program usually won't vary each time it is run, it may not find some bugs that manual testing will. Automated software testing is never a complete substitute for manual testing. Definition: Software testing assisted with software tools that require no operator input, analysis, or evaluation. Benefits: Fast Runs tests faster than human users. Reliable Tests perform precisely the same operations each time they run, thereby eliminating human errors. Repeatable You can test how the Web site or application reacts after repeated execution of the same operations. Programmab le You can program sophisticated tests that bring out hidden information.

Transcript of Selenium Remote Control

Page 1: Selenium Remote Control

Selenium Remote Control Information and Installation Procedure

Automation Testing: Introduction

Software testing using an automatic test program will generally avoid the errors that humans make when they get tired after multiple repetitions. The test program won't skip any tests by mistake. The test program can also record the results of the test accurately. The results can be automatically fed into a database that may provide useful statistics on how well the software development process is going. On the other hand, software that is tested manually will be tested with a randomness that helps find bugs in more varied situations. Since a software program usually won't vary each time it is run, it may not find some bugs that manual testing will. Automated software testing is never a complete substitute for manual testing.

Definition:

Software testing assisted with software tools that require no operator input, analysis, or evaluation.

Benefits:

Fast Runs tests faster than human users.

Reliable Tests perform precisely the same operations each time they run, thereby eliminating human errors.

Repeatable You can test how the Web site or application reacts after repeated execution of the same operations.

Programmable You can program sophisticated tests that bring out hidden information.

About Selenium:

(1) Selenium is an open-source functional testing tool written by ThoughtWorks (Read more here:http://selenium.thoughtworks.com, http://www.openqa.org/selenium). It is the only open-source testing tool that supports a large variety of browsers and operating systems.

(2) It is implemented entirely in JavaScript and runs inside the web browser itself.

(3) Selenium Core is a test tool for web applications, its tests run directly in a browser, just as real users do.

Page 2: Selenium Remote Control

About Selenium Core:

(1) Selenium Core tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux and Macintosh. No other test tool covers such a wide variety of platforms.

(2) Browser Compatibility Testing> Test your application to see if it works correctly on different browsers and operating systems. The same script can run on any Selenium platform.

(3) System functional testing> Create regression tests to verify application functionality and user acceptance.

About Selenium IDE:

(1) Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record (that records mouse and keyboard actions as Selenium commands we can save as test scripts, saving labor and reducing mistakes), edit and debug tests.

(2) Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run.

Page 3: Selenium Remote Control

(3) Selenium IDE is not only recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With auto complete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.

Selenium IDE Features:

(1) Easy record and playback.(2) Intelligent field selection will use IDs, names, or XPath as needed.(3) Auto Complete for all common Selenium Commands.(4) Walk through tests.(5) Debug and set breakpoints.(6) Save tests in HTML, Java, C#, Perl, Python, and in Ruby Scripts format.(7) Option to automatically assert the title of every page.

Page 4: Selenium Remote Control

Selenium Platform and Browser Compatibility:

(1) Supported Platforms:

(i) Windows:

Known Working:

(a) Internet Explorer 6.0 and 7.0(b) Firefox 1.5.0.8 to 2.0(c) Opera 8.5.4 and 9.0.2

Should Work:

(a) Firefox 0.8 to 2.0(b) Mozilla Suite 1.6+, 1.7+(c) Seamonkey 1.0(d) Opera 8.5+, 9

(ii) Mac OS X: Known Working:

(a) Firefox 1.5.0.4 to 2.0 Should work:

(a) Safari 1.3+ (b) Firefox 0.8 to 2.0(c) Camino 1.0a1(d) Mozilla Suite 1.6+,1.7+(e) SeaMonkey 1.0

Not Yet Supported:

(a) OmniWeb

(iii) Linux: Known Working:

(a) Firefox 1.5.0.8 and 2.0(b) Opera 9.0.2(c) Konqueror 3.5.3

Page 5: Selenium Remote Control

Should work:

(a) Firefox 0.8 to 2.0(b) Mozilla Suite 1.6+,1.7+(c) Konqueror 3.5+(d) Opera 8.5+, 9

Installation Procedure of Selenium-Remote-Control:

(1) The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 1.5.0 or higher in order to start. You may already have it installed. Try running this from the command line:

java –version

You should see a brief message telling you what version of Java is installed, like this:

java version "1.5.0_07"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode)

If you see an error message instead, you may need to install the JRE (http://www.java.com/en/download/manual.jsp),

Click on ‘Download’ button displaying after Windows (Offline Installation) and in stall the Java Runtime Environment.

Or you may need to add it to your PATH environment variable if Java Runtime Environment was already installed.

For this example, you'll also need to make sure that you have a supported browser installed.

Windows:

(i) If you're using Windows XP or Windows 2003, you can just use Internet Explorer for this example, or install Mozilla Firefox or Opera.

(ii) If you're using Windows 2000, you'll need to install reg.exe in order to use Internet Explorer, but Firefox should work regardless.

Add your browser executable to your PATH environment variable. (If you do not explicitly add your browser's installation directory to the PATH, then you must install your browser in its standard location; Firefox's standard location is "c:\

Page 6: Selenium Remote Control

Program Files\Mozilla Firefox\firefox.exe"; Internet Explorer's standard location is "c:\Program Files\Internet Explorer\iexplore.exe".)

(2) Installing ActivePerl latest build:

Go to http://www.activestate.com/Products/ActivePerl/ , download latest active perl build(ActivePerl 5.8.8.819(latest version as on 05/12/2006)) and install it.

(3) Installing latest Selenium-Remote-Control build:

Go to http://www.openqa.org/selenium-rc/, download latest selenium-remote-control build (0.9.0) zip file and extract all files to a folder (For Ex: Selenium-Remote-Control-0.9.0(latest version as on 05/12/2006)).

Place this folder in the drive where ActivePerl was installed.

(4) Installing the Selenium Perl Client Driver:

Go to http://search.cpan.org/~lukec/Test-WWW-Selenium/, download latest selenium perl client driver (1.10) zip file and extract all files to a folder (For Ex: Test-www-Selenium-1.10)

Place this folder in //Perl/bin/Test-WWW-Selenium-1.10 directory where Active Perl was installed.

Now, Open command prompt, open //Perl/bin/Test-WWW-Selenium-1.10 (latest version as on 05/12/2006) path in the drive it was installed.

(i) You'll need to run Perl on "Makefile.PL" to autogenerate a makefile, run the below command at command prompt

Drive Letter: \Perl\bin\Test-WWW-Selenium-1.10> perl Makefile.PL

(ii) Then run “nmake” command at command prompt.

Drive Letter:\Perl\bin\Test-WWW-Selenium-1.10> nmake

Note: Do not specify any filename after nmake. By default it takes Makefile.PL as a file parameter.

Small Reference:

Make

nmake - If you download modules from CPAN, you will often need to install them with the 'make' utility. NMAKE15.EXE is a self-extracting zip file. When it's

Page 7: Selenium Remote Control

executed, it will create 3 files on your disk (nmake.exe, nmake.err, and readme.txt). Move nmake.* to c:\perl\bin, which should be on the path. Then you can run this standard perl command set for installing modules:

(iii) then run “nmake test” command at command prompt.

Drive Letter:\Perl\bin\Test-WWW-Selenium-1.10> nmake test

After running this command, displays results with total number of tests, tests passed, tests failed, % of tests failed. You need not worry about these statistics. This is a bug filed under Selenium-Remote-Control. But, still you can go ahead from this step and execute Automated Test Script.

(iv) and then run "nmake install" to install it into your Perl distribution.

Drive Letter:\Perl\bin\Test-WWW-Selenium-1.10> nmake install

Note that this Makefile is incompatible with cygwin's GNU make; on Windows you should use nmake instead. (Note that nmake comes along with ActiveState Perl; it should already be available in your Perl\bin directory.)

(4) Using the Selenium Perl Client Driver:

Once you've installed the Perl Client Driver in one way or another, you'll need to use its modules. Just as there's more than one way to install the Perl Client Driver, there is also more than one way to use it.

First, make sure you've already started the Selenium Server separately in another process. The Selenium Server should remain up and running throughout this process; you shouldn't need to start/stop it each time you use the Client Driver. (Though, of course, if you need to start and stop the server, you certainly can, just by automatically starting it from the command line.)

Go to command prompt, open the drive where ‘Selenium-Remote-Control-0.9.0’

Run the below sequence of commands at command prompt:

Drive Letter: \cd Selenium-Remote-Control-0.9.0

Drive Letter:\Selenium-Remote-Control-0.9.0> cd Server

Drive Letter: \Selenium-Remote-Control-0.9.0\Server>java –jar selenium-server. jar –port 8080

Note: Please make sure the port number should be same in Selenium automated test script and when starting the selenium server jar file.

Page 8: Selenium Remote Control

If you're going to use the driver for automated testing, you may prefer to use Test::WWW::Selenium instead. Test::WWW::Selenium subclasses WWW::Selenium and provides convenient testing functions, suitable for use with Test::More. Test::WWW::Selenium does not require explicit start/stop commands (since these will be handled during test cleanup), and allows you to quickly make any Selenium method a test simply by adding the suffix "_ok" to any Selenium method. Hence, instead of using $sel->click you can use $sel->click_ok to make it a test. In addition, for each Selenium getter (get_title, ...) there are six autogenerated methods (<getter>_is, <getter>_isnt, <getter>_like, <getter>_unlike, <getter>_contains, <getter>_lacks) to check the value of the attribute).

How to execute Selenium Perl Scripts:

(1) Created a folder ‘Smoke Tests’ in \\Perl\bin\ where Active Perl was installed, keep all your smoke test scripts in ‘Smoke Tests’ folder.

(2) Make sure the port number defined in Perl Test Script and in Selenium Server jar file is same. (3) Start the Selenium-server.jar file from command prompt.

For Ex: Drive Letter:\Selenium-Remote-Control-0.9.0\Server\Java Selenium-server.jar –port 8080

(4) Open another command prompt and follow the below steps to execute selenium perl script:

Change to Smoke Test Scripts directory from root where active perl was installed.

Drive Letter:>cd Perl\bin\Smoke Tests

Drive Letter:\Perl\bin\Smoke Tests>

Execute perl test script from command prompt by typing the following command

Drive Letter:\Perl\bin\Smoke Tests>Perl filename.pl

Definitions:

Selenium RC - Selenium Remote Control.

Client Driver - A program that intends to send commands to the browser. Normally the Client Driver is an automated test. The Client Driver is normally not a web browser. Normally a Client Driver relies on a Server to transmit commands to the browser.

Page 9: Selenium Remote Control

Client - A Client Driver. The term "Client" by itself is discouraged, because it is easily confused with the browser.

Driver - A Client Driver. The term "Driver" by itself is discouraged, because it is easily confused with the Client and the Server considered as a single unit.

Server - A program designed to accept HTTP requests from Client Drivers and respond with the results of those commands.

Selenium Core - The product that defines the core HTML/JS standard for Selenium. It defines all Selenium Commands that can be performed as well as the communication protocol between the Selenium Server and the Browser.

Selenium Command - An browser-level action that is handled by Selenium Core.

Server Command - A Selenium Command to be handled by the Selenium Server itself, and is not handled by Selenium Core.

Command - A generic term describing either a Selenium Command or the Server Command.

Command Request - A request initiated by the Client Driver to the Server, requesting that the Server perform a Command (possibly by passing it to Selenium Core) and return the result.

Command Response - The Server's response to the Client Driver's Command Request.

HTTP Parameters - Name/value pairs that have been URL encoded in the manner of an HTML form data set. In HTTP GET requests, HTTP Parameters MUST appear in the URL of the request. In HTTP POST requests, HTTP Parameters MUST be encoded in the body of the HTTP request. (Surprisingly, this standard is not defined in any HTTP or URL RFC, but is only defined in the specifications for HTML [1].)

Parameters - A short name for HTTP GET Parameters. When used in this way, "Parameters" will always be capitalized.

Browser Session - A testing session associated with a web browser. Commands may be run on a particular Browser Session.

Session ID - A string identifying a Browser Session.

Result Body - The body of the HTTP Command Response.

Accessor - A Command that is designed to return data (one or more strings, numbers, booleans) to the Client Driver. ("Accessor Command" is redundant, but the term may be used for clarity.)

Page 10: Selenium Remote Control

Accessor Request - A Command Request for an Accessor.Accessor Response - A Command Response from an Accessor Command, whose result body will contain the Accessor's returned data.

Action - A Command that is not an Accessor. An Action returns no data.Action Request - A Command Request for an Action.Action Response - A Command Response from an Action.

References:

(1) For complete reference about selenium automated testing tool

http://www.openqa.org/

(2) For configuration of perl client with selenium

http://search.cpan.org/src/LUKEC/Test-WWW-Selenium-1.10/README

(3) For complete selelnium perl scripting commands

http://www.openqa.org/selenium-rc/perl/index.html