Selenium Interview Questions and Answers For Freshers and Experienced

0
4881
Selenium Interview Questions and Answers
Selenium Interview Questions and Answers

Selenium Interview Questions and Answers For Freshers and Experienced

Here we will discuss Selenium interview questions and answers. Firstly we will see What is Selenium? Selenium is an open-source, automated testing tool used to test web applications across various browsers. So, here’s the sad part, Selenium can only test web applications. Desktop and mobile apps cannot be tested using Selenium. However, other tools, like HP’s QTP and Appium, among others, can be used to test software and mobile applications. 

A list of most frequently asked selenium interview questions and answers are given below.

#1  What is Selenium? What are the different Selenium components?

Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms. Due to its existence in the open-source community, it has become one of the most accepted tools amongst testing professionals.

Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason, it is referred to as a Suite. Each of these tools is designed to cater to different testing and test environment requirements.

The suite package constitutes the following sets of tools:

  • Selenium Integrated Development Environment (IDE) – Selenium IDE is a record and playback tool. It is distributed as a Firefox Plugin.
  • Selenium Remote Control (RC) – Selenium RC is a server that allows a user to create test scripts in the desired programming language. It also allows executing test scripts within the large spectrum of browsers.
  • Selenium WebDriver – WebDriver is a different tool altogether that has various advantages over Selenium RC. WebDriver directly communicates with the web browser and uses its native compatibility to automate.
  • Selenium Grid – Selenium Grid is used to distribute your test execution on multiple platforms and environments concurrently.

#2 What are the limitations of Selenium testing? 

  1. Unavailability of reliable tech support: Since Selenium is an open-source tool, it does not have dedicated tech support to resolve the user queries. 
  2. Tests web applications only: Selenium needs to be integrated with third-party tools like Appium and TestNG to test desktop and mobile applications.
  3. Limited support for image testing.
  4. No built-in reporting and test management facility: Selenium has to be integrated with tools like TestNG, or JUnit among others to facilitate test reporting and management.
  5. May require the knowledge of programming languages: Selenium WebDriver expects the user to have some basic knowledge about programming. 

#3 What are the testing types supported by Selenium? 

Selenium supports Regression testing and Functional testing. 

Regression testing – It is a full or partial selection of already executed test cases that are re-executed to ensure existing functionalities work fine.

The steps involved are – 

  1. Re-testing: All tests in the existing test suite are executed. It proves to be very expensive and time-consuming.
  2. Regression test selection: Tests are classified as feature tests, integration tests,  and the end to end tests. In this step, some of the tests are selected.
  3. Prioritization of test cases: The selected test cases are prioritized based on business impact and critical functionalities.

Functional testing – Functional Testing involves the verification of every function of the application with the required specification. 

The following are the steps involved:

  1. Identify test input
  2. Compute test outcome
  3. Execute test
  4. Compare the test outcome with the actual outcome 

#4  What is Automation Testing?

Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves the use of a separate testing tool that lets you create test scripts that can be executed repeatedly and don’t require any manual intervention.

#5  What are the benefits of Automation Testing?

Benefits of Automation testing are:

  1. Supports execution of repeated test cases
  2. Aids in testing a large test matrix
  3. Enables parallel execution
  4. Encourages unattended execution
  5. Improves accuracy thereby reducing human-generated errors
  6. Saves time and money

Selenium interview questions and answers

#6 What is the difference between assert and verify commands?

Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.

Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.

#7  What is an XPath?

XPath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, XPath can be used to locate HTML elements.

The fundamental behind locating elements using XPath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

#8 What is the difference between “/” and “//” in Xpath?

Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.

Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.

#9 What is Object Repository?

An object repository is an essential entity in any UI automation which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

#10  Explain how Selenium Grid works?

Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test. With the entire test suite, it allows for running tests in parallel.

Selenium interview questions and answers

#11  Can we use Selenium grid for performance testing?

Yes. But not as effectively as a dedicated Performance Testing tool like Loadrunner.

#12  List the advantages of Webdriver over Selenium Server?

  • If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
  • Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
  • Selenium Web driver makes direct calls to browser using each browsers native support for automation, while Selenium RC requires selenium server to inject Javascript into the browser

#13 Mention what are the capabilities of Selenium WebDriver or Selenium 2.0?

WebDriver should be used when requiring improvement support for

  • Handling multiple frames, pop ups , multiple browser windows and alerts
  • Page navigation and drag & drop
  • Ajax based UI elements
  • Multi browser testing including improved functionality for browser not well supported by Selenium 1.0

#14 Explain what can cause a Selenium IDE test to fail?

  • 1. When a locator has changed and Selenium IDE cannot locate the element
  • 2. When element Selenium IDE waiting to access did not appear on the web page and the operation timed out
  • 3. When element Selenium IDE was trying to access was not created

#15 Explain how you can debug the tests in Selenium IDE?

  • Insert a break point from the location where you want to execute step by step
  • Run the test case
  • At the given break point execution will be paused
  • To continues with the next step click on the Blue button
  • To run commands at a time click on run button

Selenium interview questions and answers

#16 From Selenium IDE how you can execute a single line?

From Selenium IDE single line command can be executed in two ways

  • Select “Execute this command” by right clicking on the command in Selenium IDE
  • Press “X” key on the keyboard after selecting the command in Selenium IDE

#17 What is selenium RC (Remote Control)?

Selenium IDE have limitations in terms of browser support and language support. By using Selenium RC limitation can be diminished.

  • On different platforms and  different web browser for automating web application  selenium RC is used with languages like Java, C#, Perl, Python
  • Selenium RC is a java based and using any language it can interact with the web application
  • Using server you can bypass the restriction and run your automation script running against any web application

#18 Why Selenium RC is used?

Selenium IDE does not directly support many functions like condition statements, Iteration, logging and reporting of test results, unexpected error handling, and so on as IDE supports only HTML language.  To handle such issues Selenium RC is used it supports the language like Perl, Ruby, Python, PHP using these languages we can write the program to achieve the IDE issues.

#19 Explain what is the main difference between web-driver and RC?

The main difference between Selenium RC and Webdriver is that, selenium RC injects javascript function into browsers when the page is loaded. On the other hand, Selenium Webdriver drives the browser using browsers built in support.

#20 How Selenium grid hub keeps in touch with RC slave machine?

At predefined time selenium grid hub keeps polling all RC slaves to make sure it is available for testing.  The deciding parameter is called “remoteControlPollingIntervalSeconds” and is defined in “grid_configuration.yml”file

Advance Level – Selenium interview questions and answers

#20 How can we launch different browsers in Selenium WebDriver?

We have to create an instance of a driver of that particular browser.

WebDriver driver =newFirefoxDriver();  

Here, “WebDriver” is an interface, and we are creating a reference variable “driver” of type WebDriver, instantiated using “FireFoxDriver” class.

#21  Write a code snippet to launch Firefox browser in WebDriver.

 public class FirefoxBrowserLaunchDemo {  
public static void main(String[] args) {  
//Creating a driver object referencing WebDriver interface  
WebDriver driver;  
//Setting webdriver.gecko.driver property  
System.setProperty("webdriver.gecko.driver", pathToGeckoDriver + "\\geckodriver.exe");  
//Instantiating driver object and launching browser  
driver = newFirefoxDriver();  
//Using get() method to open a webpage  
driver.get("http://javatpoint.com");  
//Closing the browser  
driver.quit();  
    }  
}  

#22  Write a code snippet to launch Chrome browser in WebDriver.

 public class ChromeBrowserLaunchDemo {  
public static void main(String[] args) {  
//Creating a driver object referencing WebDriver interface  
WebDriver driver;  
//Setting the webdriver.chrome.driver property to its executable's location  
System.setProperty("webdriver.chrome.driver", "/lib/chromeDriver/chromedriver.exe");  
//Instantiating driver object  
driver = newChromeDriver();  
//Using get() method to open a webpage  
driver.get("http://javatpoint.com");  
//Closing the browser  
driver.quit();  
    }  
}  

#23  Write a code snippet to launch Internet Explorer browser in WebDriver.

 public class IEBrowserLaunchDemo {  
public static void main(String[] args) {  
//Creating a driver object referencing WebDriver interface  
WebDriver driver;  
//Setting the webdriver.ie.driver property to its executable's location  
System.setProperty("webdriver.ie.driver", "/lib/IEDriverServer/IEDriverServer.exe");  
//Instantiating driver object  
driver = newInternetExplorerDriver();  
//Using get() method to open a webpage  
driver.get("http://javatpoint.com");  
//Closing the browser  
driver.quit();  
    }  
}  

#24  Write a code snippet to perform right-click an element in WebDriver.

We will use Action class to generate user event like right-click an element in WebDriver.

Actions action = newActions(driver);  
WebElement element = driver.findElement(By.id("elementId"));  
action.contextClick(element).perform();  

#25  Write a code snippet to perform mouse hover in WebDriver.

 Actions action = newActions(driver);  
WebElement element = driver.findElement(By.id("elementId"));  
action.moveToElement(element).perform();  

#26 How do you perform drag and drop operation in WebDriver?

 Code snippet to perform drag and drop operation:
//WebElement on which drag and drop operation needs to be performed  
WebElementfromWebElement = driver.findElement(By Locator of fromWebElement);  
//WebElement to which the above object is dropped  
WebElementtoWebElement = driver.findElement(By Locator of toWebElement);  
//Creating object of Actions class to build composite actions  
Actions builder = newActions(driver);  
//Building a drag and drop action  
Action dragAndDrop = builder.clickAndHold(fromWebElement)  
             .moveToElement(toWebElement)  
             .release(toWebElement)  
         .build();  
//Performing the drag and drop action  
dragAndDrop.perform();  

#27  What are the different methods to refresh a web page in WebDriver?

There are multiple ways of refreshing a page in Webdriver.

  • Using driver.navigate command –
    • driver.navigate().refresh();  
  • Using driver.getCurrentUrl() with driver.get() command –
    • driver.get(driver.getCurrentUrl());  
  • Using driver.getCurrentUrl() with driver.navigate() command –
    • driver.navigate().to(driver.getCurrentUrl());  
  • Pressing an F5 key on any textbox using the sendKeys command –
    • driver.findElement(By textboxLocator).sendKeys(Keys.F5);  
  • Passing ascii value of the F5 key, i.e., “\uE035” using the sendKeys command –
    • driver.findElement(By textboxLocator).sendKeys(“\uE035”);  

Check it out Latest Jobs for Selenium Developer: Click here

Join Telegram Group of Daily Jobs Updates for 2010-2023 Batch: Click Here

If You Want To Get More Daily Such Jobs Updates, Career Advice Then Join the Telegram Group From Above Link And Never Miss Update.

Wipro Elite NLTH 2021 Registration has been Started: Click here

Accenture Hiring Freshers of Package 4.5 LPA Across India: Click here

Why You’re Not Getting Response From Recruiter?: Click here

Top 5 High Salary Jobs in India IT Sector 2020: Click here

How To Get a Job Easily: Professional Advice For Job Seekers: Click here

A Leadership Guide For How To Win Hearts and Minds: Click here

COVID-19 Live Tracker India & Coronavirus Live Update: Click here

Career Tips for Freshers: Top 7 Hacks To Land Your Target JobClick here

Top 5 Best Indian Car Launches In December ahead: Click here

Feel Like Demotivated? Check Out our Motivation For You: Click here

Top 5 Best Mobile Tracking App in 2021 For Mobile & PC: Click here

5 Proven Tips For How To Look Beautiful and Attractive: Click here

Home Workouts During The Lockdown For Fitness Freaks: Click here

PUBG will be soon launched Registered as an Indian Company: Click here

LEAVE A REPLY

Please enter your comment!
Please enter your name here