Showing posts with label Quality Assurance. Show all posts
Showing posts with label Quality Assurance. Show all posts

Wednesday, 30 September 2015

Challenges faced while executing Selenium Scripts



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.

Tuesday, 8 September 2015

Selenium Implementation – A conceptual Overview



Selenium is one of the most trending tools currently in the market for automated cross browser testing of web applications. There is no specific guideline for implementing Selenium, however, there are several methodologies that can be followed to successfully leverage the features of Selenium.



Evaluate the Standards of the Organization:

For implementing a new software practice in an organization, the new software tool needs to be tested in terms economic and technical feasibility for the organization. 

Before implementing Selenium, its pros and cons should be well evaluated against the organization’s requirements. 

Selenium is only used to test web applications. The entire coverage provided by Selenium testing should be documented and well communicated to the team who will be using it. 

Selenium supports a large set of popular programming languages. However, if the implementation team uses a programming language that is not supported by Selenium, they will experience difficulties in the transition. 

Implementing a Framework 

The most naive way to use Selenium is to code a script for each test. This may seem as a very potential way of achieving full test coverage. But this same methodology may lead to future standstills due to a number of reasons.  Tests should stable, consistent, easily understandable and that which can be changed easily. This requires a framework to be in place. While implementing a framework can be time consuming, it will pay off enormously in the future.

Code Standardization

Conforming to an existing naming and documentation convention is an important aspect of any automation process. It is equally important to develop codes that can be reused. It can be a constructive initiative to train the automation developers on the fundamentals of software development techniques.

Externalization of the Configuration

The most common failure in software automation is when a new software build is released, the already developed automation scripts fail to test them successfully. To avoid such inconsistencies, the automated tests should be consistent and adaptable. This can be achieved in the following ways:

-          Making the automation self-aware by anticipating dynamic functionalities and accommodating them whenever possible.

-          Configurable values should be exposed whenever possible. A majority of the maintenance issues is caused by tweaking object identification. This is because Selenium provides no object identification strategy at all.

-          The naming conventions and the other coding standards should be strictly followed.  A failure to adhere to these conventions may lead to hours of debugging efforts.

-          Hard coding can seem easy and is mainly practiced by the ignorant or novice programmers. Specifying fixed values which are potentially configurable in the future, call for changes in the code for maintenance in the future.

Logging and Reporting

Logs and reports help to determine the pass or failure of tests, determine test coverage, debug test scripts, collect the debug report and access screen captures as well. Selenium lacks in logging and reporting. Without results and reports, test automation is of no use. 

While implementing these features, the best approach is to separate the concept of logging and reporting. Logging should be reserved for technical details while reports serve better as HTML or other portable readable format. Reports should also contain the execution details of the test cases and the environment in which they were run.

The client will always ask for the test report and it should be ensured that the test automation serves its purpose for which it was implemented in the first place.

Conclusion:

Which part of the application needs to be tested, the user expectations, project timeline, priorities determined by the project managers are contributing factors in determining the implementation practices. Thus, the best implementation practices for Selenium may be different for different projects and requires careful consideration of all the aspects.

Monday, 24 August 2015

The pros and cons of Selenium Automated Testing




Selenium is an open-source automated testing tool designed for cross-browser application testing. According to SeleniumHQ -  'Selenium automates browsers'. How we harness this power completely depends on our strategies. Selenium automates web browsers as well as the web-based administration tasks.  There is a high probability that Selenium will be a native component of most of the popular browsers in the near future.




Knowing about Selenium

The initial release of Selenium had four main components. It is referred to as SeleniumRC

-          Selenium Integrated Development Environment(IDE)
-          Selenium Remote Control - Selenium(RC)
-          Web Driver
-          Selenium Grid

Later, the component Selenium(RC) and WebDriver were merged to form Selenium 2, also known as Selenium WebDriver. Selenium RC has been officially deprecated.

Selenium IDE: It can be implemented as Firefox extension. It allows us to record, edit and debug tests.  It is a complete Integrated Development Environment for Selenium scripts. It is an ideal environment for Selenium tests with its autocomplete support, optional recording capability and editable test scripts.

Selenium WebDriver: It is the primary feature of Selenium2. It is the first cross platform testing framework which could control the web browser from the operating system level.  It is a simple and more concise Object Oriented programming interface. Selenium WebDriver was developed to provide enhanced support to dynamic webpages where elements and contents of a page change without reloading the page.  Here, tests need to be written in Java. The implementing classes used are listed as follows:

-          AndroidDriver
-          CromeDriverFirefoxDriver
-          InternetExplorerDriver
-          SafariDriver 
-          HtmlUnitDriver
-          EventFiringWebDriver
-          RemoteWebDriver
-          PhantomJSDriver

Selenium Grid: Selenium Grid was developed to minimize the testing execution time as much as possible. It captured browser screen shots and sent out Selenium commands to different machines simultaneously. It works on the hub-nodes concept.  The hub acting as the main source of Selenium, commands to each connected node.

Pros and Cons of Selenium Automated Testing

The advantages of using Selenium are as follows:

-          Low Cost Tool – Since it is an open source tool it can be easily downloaded and programmers can easily use the tools to automate the web application testing in any scripting language.

-          Browser Compatibility Testing : Applications can be easily tested across multiple web browsers

-          Supports multiple programming languages: The Selenium client languages can be easily imported into popular languages such as Net Beans, .net, Eclipse etc.

-          Multiple Testing Frameworks: It supports a variety of testing frameworks such as JUnit, PHPUnit and TestNg

-          Easy Integration with the Eco system: It can be integrated with various kinds of test suites such as Selenium Grid, Ometry, Saucelabs etc.

-          AJAX Support: It supports for ajax functionalities and helps to monitor changes in content without page reload.

-          Open for Enhancement: Since it is open source, developers are free to expand the Selenium functionalities for more complex testing.

-          Enables Comprehensive Testing: It can be used for Functional, Regression, Usability and UAT Testing.

-          Test Driven Development: It is mainly used in the Agile and Extreme Programming community areas.

The various disadvantages of Selenium Testing are as follows:

-          Testing Roadblocks: It may show erratic or unpredictable behavior after injection of Selenium code into HTML source files for testing.

-          Finding Locators: Common attributes like Names, IDs, XPATH, DOM need to be located using firebug.

-          Limited support from browsers: To run test scripts on multiple browsers, they need to be written on Selenium IDE with Selenium core. Otherwise, the testing can only be carried out on Mozilla. Data Driven Tests are not supported by this framework. 

-          Implementation difference may slow down the performance of certain methods.


Selenium is at the core of many browser automation tools, APIs and frameworks. Recently, HP has enhanced its Unified Functional Testing(HP UFT) Tool and released LeanFT(Lean Functional Tool) which integrates the open-source Selenium features with that of its UFT Tool features.

Conclusion:

High quality documents and guides are available for Selenium which makes its learning and practice easier. Selenium is by far the most advantageous automated testing tools in terms of cost and flexibility.