Comparing Automated Testing Tools: Selenium, TestComplete, Ranorex, and more. JavaScript, Ruby, and Perl, and runs on all three main desktop platforms: Windows, Mac, and Linux. It’s a robust testing tool that directly communicates with a browser to automate. An open-source tool with the same API as Selenium WebDriver, you can utilize. Damien Saunders If you own a Mac and want to get started with Selenium for Automated Testing of your web apps, then you’re already most of the way there. The Mac operating system already offers a number of baked in solutions and command line tools like Python, Ruby and Java. Objective: To show how to set up a Selenium testing environment locally and run tests with it, and how to integrate it with tools like Sauce Labs and BrowserStack. Selenium is the most popular browser automation tool. There are other ways, but the best way to use Selenium is via WebDriver, a. May 05, 2017 This blog will tell you what is selenium & why it is the best tool in the market for testing web applications by comparing it with other testing tools. So, that is the need for software testing. But, what is Selenium? Is it a software testing tool? Windows, Mac, Linux, Android, iOS; Overcomes limitations of Selenium v1 like file upload. Selenium is a convenient and portable software testing tool specifically used for testing web applications. It acts as an API (Application Program Interface) for browser automation. Selenium is the widely used free and open source tool used for automation testing of web applications through various browsers and platforms.
- Selenium Testing Tool For Mac
- Selenium Ide
- Automated Testing Tools
- Selenium Testing Tool Tutorial
- Selenium Testing Tool Tutorial
- How To Learn Selenium Testing Tool For Beginners
Step by step guide to Setup and Configure Jenkins with Selenium:
Selenium 2 (aka. Selenium WebDriver)¶ Selenium 2 is the future direction of the project and the newest addition to the Selenium toolkit. This brand new automation tool provides all sorts of awesome features, including a more cohesive and object oriented API as well.
Our previous tutorial in the DevOps Series explained about Ansible Roles and Integration with Jenkins in DevOps.
Jenkins is an open source tool written in Java. It provides continuous delivery and continuous integration service for software development. It automates your manual task of code deployment process from development box – QA – Stage – Production.
Suggested Read => Precise DevOps Training Tutorial Series
Jenkins supports many plugins which you can integrate such as Git, SVN, build pipeline and many more.
The basic functionality of Jenkins is to execute a predefined list of steps on the basis of time and some events.
For example, when you want to base the execution on time you can run a job every 20 minutes or if you want to base it on an event you can do so after a new commit in a Git repository.
In this article we covered the below points:
- Jenkins usage and integration with selenium
- Creating a batch file and using it Jenkins
- Scheduling Jenkins job and added email notification
- And running selenium script from the command line
Advantages of using Jenkins are:
- It is a cross-platform and can be used on Windows, Linux, Mac OS, and Solaris environments
- It is a free and open source tool
- Widely used and well documented
- Integration with a wide variety of tool and technologies
Apart from Jenkins, we have many more tools in the market such as:
The Best Mac Zip Tool Is A Better Zip Tool. Tuesday, October 16. Encryption requires yet another utility. So, a few years ago I moved on and adopted a favorite, BetterZip. If there’s a compression file format out there that cannot be used by BetterZip, I haven’t found it. Best zip tool for mac encryption. #4 Best Disk Encryption Software - FileVault. What is Apple File Vault? FileVault is a Mac encryption software for users of OS X 10.7 (Lion) or later. It is a method of using encryption with volumes on Mac computers. Encryption and decryption are performed on the fly. Winzip can zip or unzip on Mac, and open.7z file on Mac. This Winzip app on Mac support email and share files to Dropbox and Google Drive directly with WinZip on Mac. WinZip for Mac is packed with tools to maximize your productivity and minimize file sizes.
- Anthill
- Bamboo
- Cruise Control
- Team City and many more.
What You Will Learn:
Jenkins usage and integration with selenium
Follow the below step-by-step procedure to use Jenkins with Selenium
Step #1:
Download Jenkins from the official website of Jenkins – Jenkins. Download the latest .war file. Jenkins can be started via the command line or can run in a web application server.
Refer to the below steps for the execution through the command line:
1) Open the command prompt and type java –jar and enter the path of a .war file
(Note: Click on any image for enlarged view)
2) Press enter and check if your Jenkins.war file started to run and check the status information on the command prompt console.
It should show – Jenkins is fully up and running
3) Now check whether your Jenkins is ready to use; by default, it uses port 8080.
Type “http://localhost:8080” in the browser and press enter. It will show you Jenkins UI.
It will load the Jenkins dashboard empty by default. I created some Jenkins job in the above screenshot as an example and hence, it did not load empty.
Step #2:
To use Selenium with Jenkins you need to configure Jenkins with Selenium.
Follow the below steps:
- Go to Jenkins dashboard
- Click on manage Jenkins
- Click on configure Jenkins
- Click on JDK installation – In JDK name section enter the name, under Java Home section – give your java path
The radio button, Install automatically is checked by default. You need to uncheck it because it will automatically update with the new Java version and there might be a possibility that Selenium doesn’t support the new Java version. It is better to uncheck it. Now click on apply and save.
Your Jenkins is configured with Selenium and is now ready to be used with Selenium. Both Jenkins and Selenium code is written in Java. Hence, if you give the Java path then internally it will communicate and process your job.
Step #3:
Now, create a Selenium script and a TestNG XML file. This TestNG XML file will be required for creating a batch file and we will use that batch file in Jenkins. Refer below TestNG code:
Refer below TestNG code:
Output: Before Assertion GoogleGoogle
After Assertion, GoogleGoogle Title matched
PASSED: testgooglrsearch
Create a TestNG xml file, refer below code:
Step #4:
Go to your project root directory and create a library folder.
Refer the screenshot below:
Now, add all your jar files which are required for running your Selenium script:
Step #5:
Selenium Testing Tool For Mac
Creating a batch file and using it in Jenkins
Create a batch file by following the below steps:
1) Open the notepad and type-: Java –cp bin;lib/* org.testng.TestNG testng.xml
By doing this, Java –cp will compile and execute a .class file which is located at bin directory and all our executable jar file is located at lib directory and we are using a TestNG framework so specify org.testng.TestNG. Also, specify the name of xml file which will trigger the expected TestNG script.
2) Save the file with .bat extension and check the type of file. It should be “windows batch file”. To cross-check whether the batch file is created properly, double-click the batch file and it will execute the code. Refer the below code of batch file:
Step #6:
Next, we need to add a batch file in Jenkins.
For adding the batch file follow the below steps:
1) Go to the Jenkins dashboard, create a new job in Jenkins
2) Click on a new item and enter the item name and check the freestyle project radio button
3) Click Advanced options
4) Click on use custom workspace and give your Selenium script project workspace path: “E:Automation_workspaceDemo-testNG”
5) Then go to Build and Select an option from the drop-down box, execute your build through Windows batch command
6) And give your batch file name here – “run.bat”
7) Click on apply and save
8) Click on the build now and see the build result on console output
So far we have learned:
- How to start Jenkins
- How to configure Jenkins with Selenium
- Creating your batch file and executing it through Jenkins.
As you all are aware Jenkins is a very powerful tool which is mainly used for running nightly builds. Hence, we shall now learn how to schedule your build and send email notifications to the concerned team.
Scheduling Jenkins job
For scheduling you batch file, perform the below steps:
- Go to dashboard and click on the Jenkins job
- Click on configure and then on the advanced option
- Then go to Build triggers and select Build periodically option and enter your cron job pattern
- To understand cron job pattern follow thiswiki link
I entered * * * * * which means it will run my job every minute
- Click on apply and save
There is no manual intervention. After scheduling the script, it will run at the scheduled time.
How to add email notifications
Next, we will cover how to add email notifications.
Refer the below steps:
- Go to the section ‘Manage Jenkins’
- Click on configure system
- Select Email notification
- Give your SMTP server address. I am using Gmail, as I can’t mention my official server address. To know your official server address, contact your network support team
- I entered SMTP server name = smtp.gmail.com
- Click on the advance link and check Use SMTP Authentication check box
- Provide username, password and SMTP port number; it is 465 for Gmail. Check charset and make sure it is = UTF-8
Selenium Ide
- Check your email configuration settings by clicking on Test configuration button.
- So, whenever the build passes or fails you will get the email notification.
Running Selenium script through command line
We will now see how we can run Selenium script through command prompt. This part has nothing to do with Jenkins. I am sharing this to give extra insights on Selenium.
Follow the below steps:
- Open your command prompt and go to your project base path
- Set class path for your script file; which means we are specifying that our binary and library files are stored in this location
E:Automation_workspaceDemo-testNG > set classpath = E:Automation_workspaceDemo-testNGbin;E:Automation_workspaceDemo-testNGlib*;
- Execute your testng.xml file by typing the command – java org.testng.TestNG testng.xml
- When you press enter your script will start executing and you can see the test result in the UI
Sometimes while executing your script you may face error which says, “Could not find or load main class org.testng.TestNG”
Then you need to close your command prompt and again set your classpath as mentioned above and repeat the same steps. Your error will get resolved and the script will run.
Conclusion
Integration of Jenkins with selenium provides you to run your script each time there is any change in software code and deploy the code in a new environment. With Jenkins, you can save execution history and test reports.
In short, Jenkins is very useful when you have test cases ready and you want them to run using a single click. We can create or schedule a build to run the test cases using a batch file.
Further reading => Integrate Selenium with Maven project
Note:This tutorial is a part of Selenium as well as DevOps tutorial series. Click the below link for previous and next tutorials from the DevOps series.
PREV Tutorial | NEXT Tutorial
Feel free to post your queries in the comments section below.
Recommended Reading
What is Selenium?
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP now UFT) only that Selenium focuses on automating web-based applications. Testing done using Selenium tool is usually referred as Selenium Testing.
Selenium is not just a single tool but a suite of software's, each catering to different testing needs of an organization. It has four components.
- Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (RC)
- WebDriver
- Selenium Grid
At the moment, Selenium RC and WebDriver are merged into a single framework to form Selenium 2. Selenium 1, by the way, refers to Selenium RC.
Since Selenium is a collection of different tools, it had different developers as well. Below are the key persons who made notable contributions to the Selenium Project Primarily, Selenium was created by Jason Huggins in 2004. An engineer at ThoughtWorks, he was working on a web application that required frequent testing. Having realized that the repetitious Manual Testing of their application was becoming more and more inefficient, he created a JavaScript program that would automatically control the browser's actions. He named this program as the 'JavaScriptTestRunner.' Seeing potential in this idea to help automate other web applications, he made JavaScriptRunner open-source which was later re-named as Selenium Core. |
The Same Origin Policy Issue
Same Origin policy prohibits JavaScript code from accessing elements from a domain that is different from where it was launched. Example, the HTML code in www.google.com uses a JavaScript program 'randomScript.js'. The same origin policy will only allow randomScript.js to access pages within google.com such as google.com/mail, google.com/login, or google.com/signup. However, it cannot access pages from different sites such as yahoo.com/search or guru99.com because they belong to different domains.
This is the reason why prior to Selenium RC, testers needed to install local copies of both Selenium Core (a JavaScript program) and the web server containing the web application being tested so they would belong to the same domain
Birth of Selenium Remote Control (Selenium RC)
Unfortunately; testers using Selenium Core had to install the whole application under test and the web server on their own local computers because of the restrictions imposed by the same origin policy. So another ThoughtWork's engineer, Paul Hammant, decided to create a server that will act as an HTTP proxy to 'trick' the browser into believing that Selenium Core and the web application being tested come from the same domain. This system became known as the Selenium Remote Control or Selenium 1.
Birth of Selenium Grid
Selenium Grid was developed by Patrick Lightbody to address the need of minimizing test execution times as much as possible. He initially called the system 'Hosted QA.' It was capable of capturing browser screenshots during significant stages, and also of sending out Selenium commands to different machines simultaneously.
Birth of Selenium IDE
Shinya Kasatani of Japan created Selenium IDE, a Firefox extension that can automate the browser through a record-and-playback feature. He came up with this idea to further increase the speed in creating test cases. He donated Selenium IDE to the Selenium Project in 2006.
Birth of WebDriver
Simon Stewart created WebDriver circa 2006 when browsers and web applications were becoming more powerful and more restrictive with JavaScript programs like Selenium Core. It was the first cross-platform testing framework that could control the browser from the OS level.
Birth of Selenium 2
In 2008, the whole Selenium Team decided to merge WebDriver and Selenium RC to form a more powerful tool called Selenium 2, with WebDriver being the core. Currently, Selenium RC is still being developed but only in maintenance mode. Most of the Selenium Project's efforts are now focused on Selenium 2.
So, Why the Name Selenium?
It came from a joke which Jason cracked one time to his team. Another automated testing framework was popular during Selenium's development, and it was by the company called Mercury Interactive (yes, the company who originally made QTP before it was acquired by HP). Since Selenium is a well-known antidote for Mercury poisoning, Jason suggested that name. His teammates took it, and so that is how we got to call this framework up to the present.
Brief Introduction Selenium IDE
Selenium Integrated Development Environment (IDE) is the simplest framework in the Selenium suite and is the easiest one to learn. It is a Firefox plugin that you can install as easily as you can with other plugins. However, because of its simplicity, Selenium IDE should only be used as a prototyping tool. If you want to create more advanced test cases, you will need to use either Selenium RC or WebDriver.
Brief Introduction Selenium Remote Control (Selenium RC)
Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool that allowed users to use a programming language they prefer. As of version 2.25.0, RC can support the following programming languages:
- Python
- Perl
- Ruby
Brief Introduction WebDriver
The WebDriver proves itself to be better than both Selenium IDE and Selenium RC in many aspects. It implements a more modern and stable approach in automating the browser's actions. WebDriver, unlike Selenium RC, does not rely on JavaScript for Automation. It controls the browser by directly communicating with it.
The supported languages are the same as those in Selenium RC.
- Java
- C#
- PHP
- Python
- Perl
- Ruby
Selenium Grid
Automated Testing Tools
Selenium Grid is a tool used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time. Parallel execution means running multiple tests at once.
Features:
- Enables simultaneous running of tests in multiple browsers and environments.
- Saves time enormously.
- Utilizes the hub-and-nodes concept. The hub acts as a central source of Selenium commands to each node connected to it.
Selenium Testing Tool Tutorial
Selenium IDE | WebDriver | |
---|---|---|
BrowserSupport | Mozilla Firefox | Internet Explorer versions 6 to 11, both 32 and 64-bit Microsoft Edge version 12.10240 & above ( partial support some functionalities under development) Firefox 3.0 and above Google Chrome 12.0. and above Opera 11.5 and above Android - 2.3 and above for phones and tablets (devices & emulators) iOS 3+ for phones (devices & emulators) and 3.2+ for tablets (devices & emulators) HtmlUnit 2.9 and above |
Operating System | Windows,Mac OS X,Linux | All operating systems where the browsers above can run. |
Note: Selenium WebDriver is termed as the successor of Selenium RC which has been deprecated & officially announced by SeleniumHQ.
How to Choose the Right Selenium Tool for Your Need
Selenium IDE |
|
Selenium RC |
|
WebDriver |
|
Selenium Grid |
|
Quick Test Professional(QTP) is a proprietary automated testing tool previously owned by the company Mercury Interactive before it was acquired by Hewlett-Packard in 2006. The Selenium Tool Suite has many advantages over QTP as detailed below -
Advantages of Selenium over QTP Open source, free to use, and free of charge. | Commercial. |
Highly extensible | Limited add-ons |
Can run tests across different browsers | Can only run tests in Firefox, Internet Explorer and Chrome |
Supports various operating systems | Can only be used in Windows |
Supports mobile devices | QTP Supports Mobile app test automation (iOS & Android) using HP solution called - HP Mobile Center |
Can execute tests while the browser is minimized | Needs to have the application under test to be visible on the desktop |
Can execute tests in parallel. | Can only execute in parallel but using Quality Center which is again a paid product. |
Advantages of QTP over Selenium
Selenium Testing Tool Tutorial
Can test both web and desktop applications | Can only test web applications |
Comes with a built-in object repository | Has no built-in object repository |
Automates faster than Selenium because it is a fully featured IDE. | Automates at a slower rate because it does not have a native IDE and only third party IDE can be used for development |
Data-driven testing is easier to perform because it has built-in global and local data tables. | Data-driven testing is more cumbersome since you have to rely on the programming language's capabilities for setting values for your test data |
Can access controls within the browser(such as the Favorites bar, Address bar, Back and Forward buttons, etc.) | Cannot access elements outside of the web application under test |
Provides professional customer support | No official user support is being offered. |
Has native capability to export test data into external formats | Has no native capability to export runtime data onto external formats |
Parameterization Support is built | Parameterization can be done via programming but is difficult to implement. |
Test Reports are generated automatically | No native support to generate test /bug reports. |
How To Learn Selenium Testing Tool For Beginners
Though clearly, QTP has more advanced capabilities, Selenium outweighs QTP in three main areas:
- Cost(because Selenium is completely free)
- Flexibility(because of a number of programming languages, browsers, and platforms it can support)
- Parallel testing(something that QTP is capable of but only with use of Quality Center)
Summary
- The entire Selenium Tool Suite is comprised of four components:
- Selenium IDE, a Firefox add-on that you can only use in creating relatively simple test cases and test suites.
- Selenium Remote Control, also known as Selenium 1, which is the first Selenium tool that allowed users to use programming languages in creating complex tests.
- WebDriver, the newer breakthrough that allows your test scripts to communicate directly to the browser, thereby controlling it from the OS level.
- Selenium Grid is also a tool that is used with Selenium RC to execute parallel tests across different browsers and operating systems.
- Selenium RC and WebDriver was merged to form Selenium 2.
- Selenium is more advantageous than QTP in terms of costs and flexibility. It also allows you to run tests in parallel, unlike in QTP where you are only allowed to run tests sequentially.