Selenium — Beginner’s Guide for Automation Testing

What is Selenium ?

  • It is one of the most popular open-source automated testing tool.
  • It automates web applications for testing purposes, but is certainly not limited to just that.
  • This tool gives many options for locating the UI elements and comparing expected test results against actual application behavior.

Advantages of Selenium :

  • Selenium is a free of cost open source tool.
  • Easy to learn and less hardware usage.
  • It supports Multi-Browser compatibility.
  • It supports Multiple Languages and Frameworks.

Limitations of Selenium :

  • It is a browser based testing tool. So, desktop & mobile applications can’t be automated.
  • Inability to automate a Captcha or an OTP.

Steps to configure Selenium WebDriver For windows :

  1. Install JDK (1.8 & above) & configure it.
  2. Install Eclipse (Photon or higher version) & configure it.
  3. Open Eclipse and create a workspace.
  4. Go to File New Select the Java Project Give a Project Name.
  5. Installed JRE file is selected by default.
  6. Ensure that JDK 1.8 is installed.
  7. Click Finish to complete the configuration.
  8. To know whether Selenium WebDriver is installed correctly, check the availability of JRE System Libraries on the Left pane window.

Download Selenium Jar (Selenium Standalone Server) file :

  1. Go to www.seleniumhq.org.
  2. Click on Downloads Selenium Server(Grid) and Download the Latest Stable version.

Configuring Selenium Jar file to the project :

Go to Eclipse Select the Project Right click on project and select Build Path option Configure Build Path Libraries Add External JARs Browse and select the downloaded Selenium Jar file(selenium-server-standalone-3.141.xx.jar) Apply and Close.

What is Driver Software ?

  • Selenium Webdriver is a browser automation framework that accepts commands & sends them to a browser.
  • It is implemented through a browser-specific driver which controls the browser by directly communicating with it.

Download Driver Software :

Different ways to install Driver Software :

  1. System.setProperty(key, value);

2. Copy the Driver Software and Paste into the Project.

3. Set Environment Variables

Handling Web Elements :

  • A website is a collection web pages.
  • A webpage is a collection of web elements.
  • Web elements are anything that you see on a webpage (Text Field, Image, Link, Drop-down, etc).

Locators: Commands used to perform subsequent operations and interact with Web Elements.

  1. Basic Locators
  • Id
  • name
  • class name

2. Advance Locators

  • Tag
  • CSS Selector
  • X-Path
  • Links
  1. Tag

Syntax: < Tagname attribute=”attribute_value”/>

2. CSS Selectors

(I) Tag & id
Syntax: Tag#id “input#email”

(II) Tag & Class
Syntax: Tag.class “input.inputtext”

(III) Tag & Attribute
Syntax: Tag[attribute=’attribute_value’] “input[name=’email’]”

(IV) Tag,Class & Attribute
Syntax: Tag.class[attribute=’attribute_value’] → “input.inputtext[name=’email’]”

(V) Substring

(i) Starts with (^)
Syntax: Tag[attribute^=’attribute_value’] → “input[id^=’em’]”

(ii) Ends with ($)
Syntax: Tag[attribute$=’attribute_value’] → “input[id^=’il’]”

(iii) Contains(*)
Syntax: Tag[attribute*=’attribute_value’] → “input[id*=’mai’]”

3. X-Path

(I) Absolute X-Path (/)

Path that start from the parent node (Root Node) and descend through the immediate child nodes.
Example:/html/body/div[1]/div[2]/div/form/table/tbody/tr/td[1]/input

(II) Relative X-Path (//)

Path that start from the intermediate node (child node) are only called as Relative X-Path
Example:”//[@id=’Email’]”

4. Links

Syntax: < Tag attribute = “attribute-value”/>

(I) LinkText : Links are accessed using an exact text match.
Example:”Forgotten account?”

(II) Partial LinkText : Links are accessed using a portion of their link text.
Example:”Forgotten”

— — — — — Sample Automation Code in Java — — —

Conclusion :

We have covered basic fundamental features of Selenium which would be an effective guide for beginners. Although its usability is not limited to that, we can perform parallel test execution and reduce our manual testing tasks using various components & frameworks which we will try to cover in upcoming blogs.

Originally published at http://blog.logicwind.com on July 1, 2020.

--

--

--

We craft digital products for your business growth. Development | Marketing | Branding | Strategic Partnership

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

LeetCode September Challenge(Day-15)

Web Development with HHVM and Hack: Hello World

Significance Testing and Confidence Intervals in Python with non-normal data

Web 3.0 Concept :

■ Solbody Platform

Vistara Hackathon 2017

Prometheus setup POC to production: Long term storage and HA

Custom Connectors in Power Platform

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Logicwind

Logicwind

We craft digital products for your business growth. Development | Marketing | Branding | Strategic Partnership

More from Medium

Testing API Using Postman

Test Automation Framework (Selenium with Java) — Alchemy or Translating JIRA with Selenide (with…

💻Important Commands Of MAVEN

How to automate a SOAPUI’s XML request/response testing using SOAPUI’s Maven Library + Java + Junit…