In the world of software development, it is very important never to forget about the testing phase. This topic has been heard by a developer throughout his working life: since he started studying, until he retires, going through articles like this one; and it will continue to be that way for a long time since it is the way to maintain a minimum quality in the development of any software.
In this article, we will focus on a specific case. It is a web application, developed in any language. The goal is to test the user interface, that is, check each link to where it has to go and each button do what it is supposed to do. For this we are going to use the Selenium tool.
Selenium is a set of tools that will allow us to automate web browsers to create sets of tests on web applications. It is a set of utilities that facilitate the task of obtaining test sets for web applications. This allows us to record, edit and debug test cases, which can be executed automatically.
Selenium provides the developer with an API that will allow him to interact with the page he wants to try. That is, a first step would be to provide a URL to the page you want to try. Next, we can go looking for and selecting the elements that we know that the page that we indicated at the beginning exists.
For example, you could search for a link with id “next-page” and then simulate a click on that link. This process will be done in any of the compatible languages. When executing it, we will see how a browser opens on our screen and, without touching anything; the actions that have been previously programmed are carried out. From here, the tests can be complicated everything you want. It is possible to navigate between pages, fill out forms, check the CSS, etc.
Selenium Software suite consisting of four major components:
- Selenium IDE
- Selenium Remote Control (RC)
- Selenium WebDriver
- Selenium Grid
- Easy to Implement
- Remote Control/Selenium Grid
- Continuous Updates
- Support Multiple Programming Languages and Frameworks
- Portability across Platforms
- Support across multiple browsers
Selenium offers several browsers to run the tests. For each one of them it provides a Driver. In this way there are the following: ChromeDriver, FirefoxDriver, OperaDriver, AndroidDriver and iOSDriver. If we wanted to use a browser that was not installed on our computer, but in a remote one, it would be necessary to use the Selenium-Server and Selenium-WebDriver tools simultaneously.
Selenium also includes a specific domain language for testing to write tests in a wide variety of programming languages, including Java, C #, Ruby, Groovy, Perl, Php and Python. The tests created can then be executed using most modern web browsers in different operating systems such as Windows, Linux and OS X.
- Ease of registration and execution of the tests.
- Reference to DOM objects based on ID, name or through XPath.
- Auto-completed for all commands.
- The actions can be executed step by step.
- Debugging tools and breakpoints.
- The tests can be stored in different formats.
The potential of this tool can be used for the recording of functional tests during the Generation of regression tests. With this service it is possible to obtain a battery of automated tests that can be used when it is necessary to repeat the tests.
The best-known browsers compatible with the use of Selenium are:
- Mozilla Firefox
- Google Chrome
Selenium was originally developed by Jason Huggins in 2004 and was soon joined by other specialists in testing and programming. It is an open source software under the Apache 2.0 license that can be downloaded and used free of charge. The name comes from a joke made by Huggins taunting a competitor called Mercury saying that mercury poisoning can be cured by taking selenium supplements.
Selenium consists of several tools. On one hand, Selenium IDE is an extension for Firefox that registers our activity in the browser during a certain period; this activity is translated into a series of commands that we can repeat and repeat, including assertions and warnings to perform the test itself. This series of commands can be exported as a script in very different languages: HTML, Python, Ruby, Java (JUnit), C # and some others.
This generated script can be edited to be later executed by Selenium WebDriver (formerly called Selenium RC). This implements a client API ready to be used with your favorite testing environment, which will run on a server that manages the main browsers that you have installed to perform the tests on them. That is, you can run the tests automatically on all relevant browsers, so that you do not miss any detail of your application.
Creation of Tests
Let’s see some concrete examples. First of all, let’s start creating a class with a main, which will be responsible for running the different Selenium commands. Now, what is needed is to create a driver. If we want to run the tests in Firefox, the following sentence would be enough to have control over a browser instance:
- WebDriver driver = new FirefoxDriver();
The next step would be to open the url with which we want to start testing. It would be as simple as indicating it to the driver in the following way:
It is also advisable to have an instance of the Selenium class at our disposal, since it will allow us later access to very interesting methods. For this, we can recover it in the following way:
- Selenium s = new WebDriverBackedSelenium(driver, URL);
What is Cross Browser Testing?
Check that a user interface or a Web application, in general, is able to function properly on all the most popular browsers for Internet browsing is one of the burdens connected to the developer’s work.
From this point of view the fragmentation due to vendor decisions does not make this task particularly simple, on the contrary not infrequently we find ourselves having to manage not only the incompatibilities between different applications (cross-browser) but also those between different versions of the same browser (cross-version).
The test in question ensures that these components can work as they were designed and without interruption on every type of browser. While Chrome is undoubtedly much more popular than other browsers on the market, this does not mean that you should overlook users who would like to view your website through different technologies. More than 5% of internet users continue to use Microsoft systems, more than 17% use Firefox, 3% use Safari and 1% use Opera.
Not testing your website, drive away more than 26% of visitors from the site itself. It is certainly not what you want if you want everyone to have a pleasant experience on all digital channels. Especially in the world of services related to digital payments, the quality of the user experience is directly linked to the business result.
Also consider that these statistics change if you think about the end customer. For example, if your customers are business professionals, the percentage of users that will use Microsoft will grow a lot as it is still widely used on company computers. Or if you think your users come mainly from mobile, then the statistics change substantially.
Then? How can this be done?
I hope it is now clear how important it is to include the cross-browser test in web, desktop and mobile development processes. But how can it be done exactly?
Obviously, there are several tools that can help you test different browsers. Using these tools, the simplest way to test a website on multiple browsers and devices is to create a checklist of components and manually test each checklist step on each browser and device.
If you are a developer in a small design studio that works on low-complexity web projects, this process is fairly straightforward, it shouldn’t be too burdensome and could be cheap. What you should need are half a dozen virtual machines, an iPhone and an Android smartphone. That said, we can assume an investment of around € 10,000 per year including the developer’s necessary time to do this activity (considering 2 test days per month, around 20 days per year, plus the purchase of devices and virtual machines).
However, this process leaves several questions open: Android devices are actually hundreds, virtualized browsers do not work exactly like real browsers, software versions of mobile devices have a strong impact on the proper functioning of the browser, etc. It must be considered that a developer is being taken away from his main activity (that is, developing and not testing) and, furthermore, having the system that he has created verify that the system is working properly, and it is never a good practice.
If we then move on to much more important projects, the cost increases exponentially, above all because the features to be tested increase and the management processes become increasingly complex. Fortunately, there are several cross browser testing tools available. In particular, online tool called lambdatest automation.
This online tool can perform live interactive cross-browser testing of your websites and web apps. With the help of integrated debugging tools, LambdaTest can debug in real time on both desktop and mobile browsers.
All we can say, this tool can provide you with a platform to test your web application on many browsers. LambdaTest also provides tons of features which include:
- Selenium Automation Testing
- Provide Automated Screenshots of the tests
- Check Responsiveness on all screen sizes
- Use Tunnel to test local hosted pages
- Visual Regression testing
- Resolution display testing
- Geolocation testing
This tool also offer feature of integration to third-party apps. Perform web application testing and then raise the issue to another application like Jira, Slack, GitHub etc.
Easily do Automation testing with the help of selenium grid on the cloud with all the selenium support languages. Put a maximum of 10 tests in the queue in the automation department and allow to take 25 screenshots in one go.
Automated Testing Software Features
- Cross Browser Support
- Parallel Execution
The purpose of this article was to introduce the basic concepts of Selenium to create a minimally elaborated battery of tests. There are, however, many elements and many Selenium options to analyze. For example, the WebElement class offers new possibilities to check the results obtained, as well as more options for interaction with the interface. We hope it has been helpful and that now your application has improved in reliability and quality.
In whatever way you decide to do it, the cross-browser testing process in modern web and mobile development is of primary importance. Web users today are spread over a very large number of browsers and devices, it is important to be sure that your products and services that use this digital channel are ready to reach those users, no matter which channel they are browsing.
Originally posted 2019-03-25 17:51:34. Republished by Blog Post Promoter