Selenium Tutorial | Simplilearn

Selenium is a precious testing instrument, a useful resource that every one internet software builders ought to learn about. To that finish, we current this tutorial that can assist you get familiarized with this versatile and highly effective improvement useful resource.

However earlier than we discover Selenium, let’s first handle the necessity for automation testing and the way Selenium got here into the image within the first place. 

Manual testing, a significant a part of the appliance improvement course of, sadly, has many shortcomings, chief of them being that the method is monotonous and repetitive. To beat these obstacles, Jason Huggins, an engineer at Thoughtworks, determined to automate the testing course of. He developed a JavaScript program referred to as the JavaScriptTestRunner that automated internet software testing. This program was renamed Selenium in 2004. 

Grasp essential testing ideas similar to TestNG, Selenium IDE, Selenium Grid, Selenium WebDriver with Selenium Certification Training course. Enroll now!

Selenium is an open-source, automated testing instrument used to check internet functions throughout numerous browsers. Sadly, Selenium can solely take a look at internet functions, which leaves desktop and cellular apps out within the chilly. Nevertheless, instruments like Appium and HP’s QTP, amongst others, can be utilized to check software program and cellular functions. 

selenium-1

Selenium consists of a set of instruments that facilitate the testing course of. 

selenium-2
Fig: Selenium suite

Selenium IDE 

Shinya Kasatani developed Selenium Built-in Improvement Atmosphere (IDE) in 2006. Conventionally, it’s an easy-to-use interface that information the consumer interactions to construct automated take a look at scripts. It’s a Firefox or Chrome plugin, typically used as a prototyping instrument. It was primarily developed to hurry up the creation of automation scripts. 

IDE ceased to exist in August 2017 when Firefox upgraded to the brand new Firefox 55 model, which not supported Selenium IDE. Applitools rewrote the outdated Selenium IDE and launched a brand new model not too long ago. The newest model got here with a number of developments, similar to:

  • Reusability of take a look at scripts 
  • Debugging take a look at scripts
  • Selenium facet runner
  • Provision for management circulation statements
  • Improved locator performance

selenium-3.

Now let’s take a more in-depth, extra detailed have a look at Selenium IDE. 

Putting in IDE: 

Step 1- Open the Firefox browser 

Step 2- Click on on the menu within the prime proper nook 

Step 3- Click on on Add-ons within the drop-down field.

Step 4- Click on on Discover extra add-ons and sort “Selenium IDE” 

Step 5- Click on on Add to Firefox

selenium-4

As soon as put in, the Selenium IDE icon seems on the highest proper nook of the browser. When you click on on it, a welcome message seems.

Selenium4

Recording a Take a look at

Let’s first create a brand new take a look at for a brand new venture. Present a reputation on your venture, on this instance, we are going to name it demo_project. Earlier than recording, we should specify a sound URL. The recording begins as soon as the browser navigates to this URL. Let’s navigate to the Fb login web page. 

Selenium6 

Clicking on “Start Recording” will ship you to the Fb web page and begin recording the consumer interactions. The consumer is at liberty to cease recording. All consumer actions are recorded and transformed right into a script. 

Save Your Work 

To avoid wasting the whole lot you’ve got simply carried out within the IDE, click on the save icon within the top-right nook of the IDE. It can immediate you to for a reputation and a location of the place to save lots of the venture. The result’s a single file with a.facet extension. 

Selenium7

Playback 

In-browser: You may play assessments again within the IDE by choosing the take a look at you want to play and clicking on the Play button. 

For cross-browser playback, you may make use of the command-line-runner. 

Selenium8

Selenium Distant Management (RC) 

Paul Hammant developed Selenium Remote Control. However earlier than studying about RC, let’s discover why it got here into the image within the first place. 

Initially, Selenium-Core was referred to as “JavaScriptTestRunner,” a instrument constructed by Jason Huggins in 2004. It was a set of JavaScript capabilities that interpreted and executed Selenese instructions utilizing the browser’s built-in JavaScript interpreter. Selenium-Core was then injected into the online browser. 

Now, let’s take into account a JavaScript, take a look at.js utilized by google.com. This program can entry pages like google.com/mail or google.com/login inside the google.com area.

Selenium9
Fig: Selenium RC

Nevertheless, this system can not entry parts of different domains like Yahoo.com. Native copies of Selenium-Core and the online browser needed to be put in in order that they belonged to the identical area. That is referred to as the Similar Origin Coverage, and Selenium RC was launched to deal with this limitation. The server acts as a consumer configured HTTP proxy and “tricks” the browser into believing that Selenium Core and the online software being examined share the identical origin. 

Therefore, Selenium RC is a server written in Java that makes provision for writing software assessments in numerous programming languages like Java, C#, Perl, PHP, Python, and so on. The RC server accepts instructions from the consumer program and passes them to the browser as Selenium-Core JavaScript instructions. 

Selenium10

Selenium WebDriver 

Developed by Simon Stewart in 2006, Selenium WebDriver was the primary cross-platform testing framework that would configure and management the browsers on the OS stage. It served as a programming interface to create and run take a look at circumstances. 

Selenium8

    Fig: Selenium WebDriver

Not like Selenium RC, WebDriver doesn’t require a core engine like RC and interacts natively with the browser functions. WebDriver additionally helps numerous programming languages like Python, Ruby, PHP, and Perl. It may also be built-in with frameworks like TestNG and JUnit for take a look at administration. 

Selenium WebDriver’s structure is straightforward and straightforward to grasp: 

selenium-architecture

Fig: Selenium WebDriver structure

  • Selenium take a look at script – Selenium take a look at script is the take a look at code written in any of the talked about programming languages which might be interpreted by the driving force. 
  • JSON Wire Protocol – JSON Wire Protocol offers a transport mechanism to switch knowledge between a server and a consumer. JSON Wire Protocol serves as an trade commonplace for numerous internet companies.
  • Browser drivers – Selenium makes use of drivers, particular to every browser to determine a safe reference to the browser.
  • Browsers – Selenium WebDriver helps numerous internet browsers on which to check and run functions. 

Selenium WebDriver tutorial –

  1. Download and Set up Java 8 or larger model – Set up the newest model of the Java improvement equipment. Click on here to put in it. 
  2. Download and configure Eclipse or any Java IDE of your selection – Open the URL link.

selenium-11

Scroll down the web page and click on on the newest model within the “more downloads” part.

The downloaded file will probably be a zipper file. Unzip the file in a folder of your selection. As soon as unzipped, open the .exe eclipse file

selenium-12

The following step is to configure a workspace. Choose a listing the place you need to retailer your whole initiatives and click on on the launch icon. 

selenium13

As soon as launched, the IDE workbench appears to be like one thing like this.

seleniun-14

3. Download Selenium WebDriver Java Shopper – 

  • Navigate to the official Selenium page
  • Scroll down by the online web page and find Selenium Shopper and WebDriver Language Bindings.
  • Click on on the “Download” link of Java Shopper Driver, as proven within the picture. 

selenium-15

As soon as downloaded, unzip the file in a listing. It consists of the Jar information required to configure Selenium WebDriver within the IDE. 

selenium-16

4. Download the Browser driver – The automation scripts have to be suitable with any browser. Each browser supported by Selenium comes with its driver information. These are important to run the scripts. Transferring forward, download the newest driver file from this link.

selenium-17.

5. Configure Selenium WebDriver – The ultimate step is to configure the Selenium WebDriver with the Eclipse IDE. In easy phrases, we create a brand new Java venture to construct our take a look at script.

selenium-18

Present a venture title and choose the JRE that you just want to use. It’s advisable to make use of the default JRE. Choose it and click on on end. 

selenium-19

The following and most important step is so as to add the downloaded Java executable information [Step 3]. To try this, right-click on the Mission>>Construct Path>>Configure Construct Path.

selenium-21

Choose libraries after which Add Exterior JARs.

selenium-20.

Open the folders by which you’ve saved your JAR information and choose the 2 executable JAR information. Click on on open so as to add them. 

selenium-22

Click on on the libs folder>> Choose the information>> Open 

selenium-23

When you’re carried out including the library information, click on on Apply and Shut. 

apply

With this, you might have efficiently configured the Webdriver with the Eclipse IDE. Now you can go forward and construct your first take a look at script. 

To try this, Proper-click on Src folder>>New>>Class

new-class

Let’s now create a easy take a look at script that launches the Firefox browser and opens the Fb homepage. The script is offered under. 

import

Notice: The second argument to the setProperty methodology is the location of your browser driver. In our case, we’ve got put in the gecko driver. Therefore, we paste the trail together with the title of the file. 

Click on on Run>>Run As>>Java Software

Selenium Grid 

Patrick Lightbody developed grid to attenuate take a look at execution time. Selenium Grid permits the parallel execution of assessments on totally different browsers and totally different working programs, facilitating parallel execution. Grid is exceptionally versatile and is built-in with different suite elements for simultaneous efficiency. 

grid

Fig: Selenium Grid

The Grid consists of a hub linked to a number of nodes. It receives the take a look at to be executed together with details about the working system and browser to be run on. The Grid then picks a node that conforms to the necessities (browser and platform) and passes the take a look at to that node. The node now runs the browser and executes the Selenium instructions inside it. 

Conclusion 

Hopefully, this text has helped you acquire insights into Selenium and its workings. If you need extra info, watch our videos to get a greater understanding. 

Should you’re inquisitive about launching your profession as an automation engineer, then you must earn a course certification. Take a look at Simplilearn’s Selenium Training course and hone your Selenium abilities into a sturdy and marketable useful resource!

About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *