DEV Community

Cover image for Top 10 Selenium interview questions
rahul
rahul

Posted on

Top 10 Selenium interview questions

When it comes to software development testing plays a very important role in SDLC(Software Development Life Cycle). The role of a QA tester is very important and it can't be undermined.
This article consists of the questions asked most during any Selenium Interview. Let's start with testing and its types.

Software Testing:
It's a method to check whether the software developed meets the expected demand or not and to check that it's error and bug-free.
There are two types of testing that are:
Manual Testing
Automation Testing

Manual Testing:- In this type of testing there is no use of any automated tool the test cases under execution are manually tested by the tester. It helps in the detection of bugs and errors in the software or application under test. Manual testing is a heavy process and poses a lot of challenges.

Automation Testing:- This is a testing technique in which the tests to be done are automated using scripts, tools, and software for repetitive testing. It offers a great result and a higher efficiency in comparison to manual testing.

There are various tools that help us in automating our tests some of them are i.e. Selenium, Katalon, UFT, etc.
Selenium is an open-source automation testing tool used for functional testing. However, it can only test web applications, not mobile or desktop applications. It lets us write the test cases in various programming languages i.e. Ruby, Python, C++, Java, PHP, etc. And the written test cases can be performed on various browsers as Selenium supports cross-browsers.

And if you are preparing for an interview then, this article will surely help you to ace it up.

Que-1 What is Selenium?
Ans- Selenium is an open-source automation testing tool used for functional testing. It lets us write the test cases in various programming languages i.e. Ruby, Python, C++, Java, PHP, etc. Jason Huggins developed this tool in 2004.

Que-2 What is Selenium Suite and what are its components?
Ans- Selenium is not a single component, it's a collection of tools that are required for automation testing thus it is termed as Selenium Suite. The various components integrated under this are:

Selenium IDE
It was developed to speed up the creation of automation scripts. It records the action and evaluates them to a script. It is distributed as Firefox and Chrome plug-in.

Selenium Remote Control(RC)
It is a server helping the users to create test cases in their preferred programming languages. The commands that are written in the scripts are contained here and then sent to the browser as Selenium Core Javascript commands.

Selenium WebDriver
It's a programming interface helping the users create and run test cases. It does not require an additional server.

Selenium Grid
It distributes the commands to different machines and conveys the parallel execution of our tests on cross-browser and operating systems.

Que-3 What is Selenese?
Ans- These are the commands that are used in selenium to run the test cases, selenium commands are also known as Selenese. The 3 major categories of commands are:

Action:- These commands directly interact with the web applications.

Accesses:- Users are able to store values to user-defined values.

Assertions:- As the name suggests these are used for verification purposes. i.e. Current Value is equal to the Expected Value.

Que-4 What is the major difference between the verify and assert commands?
Ans- Both assert and verify commands are used to check whether the given condition is true or false. The difference that exists between them is as:

Assert:- During assert commands if the condition is true then the tests execute else if the condition is false then the execution of the test fails.

Verify:- Verify command is regardless of the condition, the tests continue to execute even when the condition is false.

Que-5 What are the different types of locators in Selenium?
Ans- A locator can be termed as a web element that is used to identify or locate the web elements uniquely and precisely. The different types of locators that are used in selenium are:

ID
ClassName
TagName
LinkText
XPath
CSS selector
DOM

Que-6 What is the difference between “/’ and “//” in X Path?
Ans-
Single Slash ”/”:- Single slash “/” is used to create an XPath with an absolute path.
Double Slash “//”:- double slash “//” is used to create an XPath with a relative path.

Que-7 Explain the various navigation commands in selenium?
Ans- There are majorly 4 navigation commands that are supported by Selenium:

navigate().to(“URL”):- This command is used to navigate to a specific “URL”.
navigate().refresh():- This command is used to reload the elements of a web page by refreshing.
navigate().back() :- This command is used to go to the previous webpage.
navigate().forward():- This takes the user to the forward page from the current page via browser history.

Que-8 Explain how we can create right click action and mouse hover action in selenium with the help of code snippets?
Ans- In order to create the right click and mouse hover action we can use the following code snippets.
For right click action
clickAction = newAction(driver);
WebElement element = drvier.findElement (By.id(“elementId”));
action.contextClick(element).perform();

For mouse hover action
clickAction = newAction(driver);
WebElement element = drvier.findElement (By.id(“elementId”));
action.moveToElement(element).perform();

Que-9 How can we retrieve Css values or properties of an element?
Ans- In order to retrieve Css properties of any web element we can use the following syntax
Syntax: driver.findElement(By.id(“id”)).getCssValue(“name of Css Attribue”);

Example
driver.findElement(By.id(“color”)).getCssValue(“background”);

Que-10 Explain different types of Exceptions in the Selenium Web driver?
Ans- “Exception is an event(or problem) that occurs during the execution of code and disrupts the normal flow of code causing errors in the code.

The exceptions that are used in the Selenium Web driver are similar to the exceptions that are used with different programming languages i.e. Python, C++, etc. The common Exceptions used are as follows
NoSuchElementException = When an element present in the syntax cant be found on the web page, then this exception can be thrown. i.e. FindBy method can’t find a particular web page element.

NoSuchWindowException = When the web driver is trying to open the window that is not present or unavailable. i.e. invalid window.

TimeOutException = This exce[ption is thrown when the command did not complete with a specified time limit. i.e. When a particular element requested is not shown at a time.

ElementNotVisibleException = This exception is thrown when a particular web element is present on the page or DOM(Document Object Model) but not visible.

NoSuchFrameException = When the web driver is trying to switch to a frame that is not present or unavailable. i.e. invalid frame.

So, this is the end of the article. We have covered some of the important questions that are asked during the selenium interview questions. Do prepare these, so that you can excel yourself before any interview. Thanks for reading.:)

Author - Rahul Singh (Linkedin Profile)
I am an engineering graduate from MITS Gwalior. I am a tech enthusiast and an avid learner. I like to read and write about technology-related topics.

Top comments (0)