Selenium
is a suite of tools to automate web app testing across many platforms.
It is a GUI based automation tool. Initially it is built by
ThoughtWorks. It supports various browsers on various platforms
Selenium Projects
Selenium has many projects. Following projects are mostly used by testers.
- Selenium IDE (IDE)
Selenium
IDE can be used only in FireFox. It is an add-on for FireFox. User can
record the actions and can edit and debug the tests. It can be used to
identify IDs, name and XPath of objects. Only one test at a time.
- Selenium Core (CORE)
Selenium
Core is the original Javascript-based testing system. This technique
should work with any JavaScript enabled browser. It is the engine of
both, Selenium IDE and Selenium RC (driven mode), but it also can be
deployed on the desired application server. It is used specifically for
the acceptance testing.
User can record the tests using Selenium IDE
and can use the same tests to run in other browsers with minimal
modifications. It provides support to run the tests in HTA (HTML
Applications) Mode. This mode works only in IE.
- Selenium Remote Control (RC)
Selenium
Remote Control is a test tool that allows user to write automated web
application UI tests in few programming languages against any HTTP
website using any mainstream JavaScript-enabled browser. User can write
the tests (More expressive programming language than the Selenese HTML
table format) in Java, DotNet, Perl, Ruby and PHP. Also it supports few
testing frameworks.
- Selenium Grid
Selenium Grid allows easily to run multiple tests in parallel, on multiple machines, in an
heterogeneous
environment by cutting down the time required for test execution. Using
this, user can run multiple instances of Selenium Remote Control in
parallel.
Supported browsers
Selenium tools can run in following browsers.
- Internet Explorer
- FireFox
- Opera
- Safari
- Seamonkey
Supported Operating Systems
Users can execute the selenium tests in following OS.
- Windows
- Linux
- Solaris
- OS X
Supported Programming languages
Below languages are supported by Selenium RC.
- C# (DotNet)
- Java
- Perl
- Ruby
- Python
- PHP
Sample Code
Following
program tells how to launch a browser and to play around with
text,list,combobox objects we find normally in any website
import com.thoughtworks.selenium.*; |
import com.thoughtworks.selenium.DefaultSelenium; |
public class MySelenium { |
static Selenium selenium; |
public static void main(String arg[]) throws Exception |
selenium = new DefaultSelenium( "localhost" , |
selenium.windowMaximize(); |
selenium.open( "/index.html" ); |
selenium.click( "//div[@id='ge_footer']/ul/li[2]/a" ); |
val=selenium.isElementPresent( "//img[@alt='GE: imagination at work']" ); |
for (int second = 0;second<=10; second++) { |
val=selenium.isElementPresent( "//img[@alt='GE: imagination at work']" ); |
System.out.println( "Page not found :=GE: imagination at work" ); |
selenium.click( "//ul[@id='ge_secondaryNav']/li[2]/a" ); |
val1=selenium.isElementPresent( "//div[@id='secondary_content']/div/h3" ); |
for (int second = 0;second<=10; second++) { |
val1=selenium.isElementPresent( "//div[@id='secondary_content']/div/h3" ); |
System.out.println(val1); |
System.out.println( "Element not found :=GE: Other Contact Resources" ); |
selenium.click( "//input[@id='contact_type_press']" ); |
selenium.select( "//select[@id='contact_subject']" , "label=Other" ); |
selenium.select( "//select[@id='contact_country']" , "label=Algeria" ); |
selenium.type( "//input[@id='contact_email']" , "abc@vvv.com" ); |
selenium.type( "//textarea[@id='contact_comments']" , "testing" ); |
No comments:
Post a Comment