Selenium Manual
Selenium Manual
• Selenium IDE :
• Selenium Core :
Selenium Core is a test tool for web applications. Selenium Core tests run
directly in a browser. And they run in Internet Explorer, Mozilla Firefox on
Windows, Linux, and Macintosh. But to use Selenium Core we need to make
it available from the same web server as the application you want to
test(AUT).
Selenium Remote Control (RC) is a test tool that allows you to write
automated web application UI tests in any programming language against any
HTTP website using any mainstream JavaScript-enabled browser.
Open the download link using Mozilla(version: 1.5 or higher) and choose
any version of Selenium IDE and select INSTALL NOW. It will get installed
automatically. The download link is given below.
Working :
Once the installation is successfully completed, go to ‘Tools’ in the firefox
window. You can find Selenium IDE. Click on Selenium IDE. The small red
button on the right hand side gives you an indication on whether Selenium is
in recording mode or not. Click the red button to start recording and click the
red button again to stop the recording.
Run will execute the tests with the maximum possible speed. Walk will
execute them with relatively slow speed. In Step mode you will need to tell
Selenium to take small steps. Green tilted triangular button is to execute the
test. Yellow button to pause while executing the test. Blue button helps to
place checkpoints and the final green button is the Selenium Test Runner.
Test Runner gives you nice browser interface to execute your tests and
also gives summary of how many tests were executed, how many passed
and failed. It also gives similar information on commands which were passed
or failed. Test Runner is available to tests developed in HTML only.
In selenium, there is option to start a new test, save test and open the
saved test. It is also possible to export scripts. We have other self explanatory
options like encoding of test files, timeout under the Options tab. When we
access the Format tab under Options tab, we have an option as to specify
what kind of formatting we would like in the generated code as Selenium IDE
can generate code in variety of languages.
http://wiki.openqa.org/download/attachments/400/Selenium+IDE.swf?
• It is a Freeware
• Simple, Easy to install, Easy to work
• Selenium IDE is the only flavor of Selenium which allows you to record
user action on browser window
• Can also record user actions in most of the popular languages like
Java, C#, Perl, Ruby
• It will not record any operation that you do on your computer apart from
the events on Firefox browser window
• During recording if you right click on any element it will show all the
selenium commands available
• You can also edit existing command, by selecting it and editing on the
boxes available
• You can also insert/delete commands by choosing appropriate option
after right clicking
• Choose appropriate run option - i.e walk, run or test runner and review
your results
Disadvantages:
Selenium RC:
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:
If you see an error message instead, you may need to install the JRE, or
you may need to add it to your PATH environment variable if it is already
installed.
Open the link mentioned below and download Selenium RC. Extract it,
you will get Selenium Server folder and Java, Ruby, Perl, Dot Net, PHP, Python
Client folders also. Make sure that whether ‘selenium-server.jar’ file exist in the
server folder or not. Open Command window and type the command to start the
server.
Java -jar selenium-server.jar (non-interactive mode)
cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
import com.thoughtworks.selenium.*;
import junit.framework.*;
import java.util.regex.Pattern;
selenium.open("/pbn/Default.aspx");
//Checking Login using valid LoginID and valid password
selenium.type("txtLogin", "Rajasekhar.Chintha");
String Login = selenium.getValue("txtLogin");
selenium.type("txtPassword", "abcd1234");
selenium.click("link=GO");
selenium.waitForPageToLoad("30000");
selenium.selectFrame("link");
if (!Login_Name)
{
System.out.println("Failed : Text 'User : " + Login + "(Test
Analyst)' is not found");
Failed++;
}
else
{
System.out.println("Passed : Text 'User : " + Login + "(Test
Analyst)' is found");
Passed++;
}
selenium.click("link=Logout");
}
}
Note: To compile and execute the script, use the following commands
Features :
Disadvantages :
Launching Browsers:
• -port <nnnn>: The port number the selenium server should use
(default 4444)
• -timeout <nnnn>: An integer number of seconds before we should
give up
• -interactive: Puts you into interactive mode.
• -multiWindow: Puts you into a mode where the test web site executes
in a separate window, and selenium supports frames
• -forcedBrowserMode <browser>: Sets the browser mode (e.g.
"*iexplore" for all sessions, no matter what is passed to
getNewBrowserSession)
• -htmlSuite <browser> <startURL> <suiteFile> <resultFile>: Run a
single HTML Selenese (Selenium Core) suite and then exit
immediately, using the specified browser on the specified URL. You
need to specify the absolute path to the HTML test suite as well as the
path to the HTML results file we'll generate
Element Locators:
Element Locators tell Selenium which HTML element a command refers to. The
format of a locator is:
locatorType=argument
Examples:-