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.