Selenium is an
open source automated tool for testing web applications. It provides an
extensive library of test functions. It interacts with web browsers using
programming languages such as PHP, Java, .Net, C#, Ruby, Perl etc. Tests in
Selenium can be scripted in HTML tables or using these programming languages.
Selenium helps to locate UI elements. It defines the methods of comparing
pre-calculated test results with the actual real time application functions. It
supports almost all of the major web browsers and can be deployed on Linux,
Windows and Macintosh. Selenium is mainly preferred for User Acceptance
Testing.
Components
of Selenium:
There are four
components of Selenium. They can be used individually or combined with each
other to create automated testing solutions for web applications.
These four components can be defined as follows:
- Selenium IDE: Selenium Integrated Development
Environment is a plugin for Firefox that record the user interactions in the
applications for formulating test cases.
- Selenium Remote Control: Creates test cases using
the supported programming languages.
- Selenium WebDriver: It is an extension of
Selenium RC. It executes the commands directly in the browser and generates
results.
-
Selenium
Grid: This tool helps to run test cases across multiple browsers and operating
systems simultaneously minimizing the test execution time.
Challenges
of Selenium Script Execution:
-
Selenium
is unable to record the pop-ups which causes issues in executing Selenium
scripts. This is handled by applying a getAlert() function. Before running a
test script, a WebDriver script that can handle alerts needs to be imported.
This script defines the following commands:
void accept(),
void
dismiss(),
getText(),
void
sendKeys(String stringToSend)
- Events
are not triggered when values change: Selenium is unable to trigger events
automatically with changing values. Hence the command:
Selenium.FireEvent(cmbCategory,
“onchange”);
is used where, cmbCategory is
the object on which the event is fired; onchange is the event name.
- Synchronization
issues lead to timeouts: To solve this issue, a function needs to be created to
check the presence of the element. This will need to take the object locator as
the parameter and return true if the object is found. The following function
can be used:
IsElementPresent(locator)
Thread.Sleep
- SSL
Issues: Selenium Tests
may face issues with Secure Socket
Layer(SSL). This issue can be solved by trustAllSSLCertificates.
For browsers excluding firefox:
C: > java -jar c:\Selenium\selenium-server2.14.0.jar.
–trustAllSSLCertificates
For firefox:
C:> java -jar c:\Selenium\selenium-server2.14.0.jar.
-firefoxProfileTemplate /C:\Selenium\ Profile
- Flash
App Testing: Flex Monkium can be used for automation of flash apps. The source
code of the application is created by Flex Monkium and compiled with swc files.
The app and the IDE are then connected and the tests are recorded with the
IDE.
- Internet
Explorer Launch Error: The zoom level in the browser should be 100% by default.
- Error
occurs when Selenium Webdriver is run on a new Windows machine. This can be
solved by setting the following parameters:
DesiredCapabilities caps =
DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver driver = new
InternetExplorerDriver(caps);
Some
additional issues
1.
With change in the application design, the
verification code also changes.
2.
Sometimes the application stops before the
verification code is executed. When the verification code is rerun, the new
verification code is rejected and the script fails to execute.
3.
Compatibility issues occur between Selenium and
components of Java.
4.
The Element-ID of the data in the submitted
application changes regularly.
The
various components in designing Selenium test cases are as follows:
-
Page Object Model
-
Log4jLogging
-
Parameterizing using Excel
-
Exception Handling
-
Multi Browser testing
-
Capture videos
-
Capture Screenshots.
Conclusion:
The
amount of test cases tend to grow with increasing complexity of the web
application. Regression testing becomes more complex and requires longer
testing time. This necessitates the development of test automation. Selenium
reduces the cost of Functional Testing significantly over QTP.