Most Important 50 Selenium Interview Questions and Answers

Rate this interview

To prepare for your next interview on Selenium, here are some of the frequently-asked

Selenium interview questions (with answers) to help you prepare well.

Selenium is a suite of tools to automate web browsers across many platforms. It is a free, open-sourced application which caters to different testing requirements. This application also supports authoring of tests without having to learn a scripting language and provides a domain-specific language to writes tests in a number of popular programming language. It also runs on most of the modern browsers.

Due to the many advantages Selenium has to offer, it is one of popular testing frameworks and Selenium professionals are in great demand across the IT industry.

How many languages does Selenium support?

Table of Contents

Ans. All major languages, including C#, Java, PHP, Ruby, Python.

What is automation testing?

Ans. Automation testing or Test Automation is a process of automating the manual process to test the application/system under test.

What are the different ways to find an element?

Ans. ID, Name, Tag, Attribute, CSS, Linktext, PartialLink Text, X-path

What are the testing types supported by Selenium?

Ans. Functional testing and regression testing

What is the difference between implicit wait and explicit wait in selenium WebDriver?

Ans. When an implicit wait is implemented in tests, if WebDriver cannot find an element in the Document Object Model (DOM), it will wait for a defined amount of time for the element to appear in the DOM.

An explicit wait can be used where synchronization is needed, for example the page is loaded but we are still waiting for a call to complete and an element to appear.

Which is better –implicit wait or explicit wait?

Ans. Explicit waits are better than implicit wait. Unlike an implicit wait, you can write custom code or conditions for wait before proceeding further in the code.

When should I use Selenium IDE?

Ans. Selenium IDE is the simplest of all the tools in the package and should be a great tool for naïve users as it is easy to learn with minimal acquaintances in programming language.

Explain the difference between single (/) and double slash (//) in X-path?

Ans. Single slash (/) allows the creation of ‘absolute’ path expressions, while double slash (//) allows the creation of ‘relative’ path expressions.

What is the use of X-path?

Ans. X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.

What is the difference between type keys and type commands?

Ans. Type key populates the value attribute using JavaScript whereas type commands emulate like actual user typing

What is the difference between verify and assert commands?

Ans. Assert command allows to check whether an element is on the page or not. Verify command checks whether the element is on the page, otherwise the test will carry on executing.

What is heightened privileges browsers?

Ans. Heightened privileges browsers are similar to Proxy Injection, allows websites to do something that are not commonly permitted.

Explain what is Data-driven framework and Keyword driven?

Ans. In Data-driven framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts.

Keyword driven frameworks requires the development of data tables and keywords, independent of the test automation.

What is Object Repository?

Ans. Object repository is an essential entity in any UI automations 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.

Also Read Automation Coding standards

Mention 5 different exceptions you had in Selenium WebDriver?

Ans. The 5 different exceptions in Selenium WebDriver are WebDriver Exception, NoAlertPresentException, NoSuchWindowException, NoSuchElementException, TimeoutException

Which web driver implementation is fastest?

Ans. HTMLUnit Driver implementation is fastest

selenium interview questions

How to find more than one web element in the list?

Ans. It can be done using WebElement List. E.g.

List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

int listSize = elementList.size();

for (int i=0; i<listSize; i++)

{

serviceProviderLinks.get(i).click();

driver.navigate().back();

}

What is the difference between driver.close() and driver.quit() command?

Ans. Close() method closes the web browser window that the user is currently working on or the browser that WebDriver is currently accessing.

Quit() method closes down all the windows that the program has opened.

In which format does source view shows your script in Selenium IDE?

Ans. XML

What is Object Repository? How can we create Object Repository in Selenium?

Ans. Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values.

In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.

What is Selenese and what are the types of Selenese ?

Ans. Selenese is a selenium set of command which are used for running the test.

There are three types of Selenese – Actions, Assertions and Accessors

How you can convert any Selenium IDE tests from Selenese to another language?

Ans. The format option of Selenium IDE to convert tests into another programming language

To generate pdf reports mention what Java API is required?

Ans. API IText

What are the ways you can customize TestNG report?’

Ans. You can customize TestNG report in two ways,

– Using ITestListener Interface

– Using IReporter Interface

In Selenium what are Breakpoints and Startpoints?

Ans. A breakpoint is implemented to stop an execution to check if the code is working as expected till now.

A startpoint indicates the point from where the execution should begin.

What is Selenium composed of?

Ans. Selenium is a suite of tools for automated web testing and it is composed of Selenium IDE (Integrated Development Environment), WebDriver and RC, and Grid.

Can you tell me from where the term Selenium derived?

Ans. Well, it came from a joke made by Jason Huggins (the developer of Selenium) in an email, where he mocked one of his competitors named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. This is from where the other email recipients took the name and the rest is history.

Why should you use Selenium as a test tool?

Ans. Selenium is a free and open source tool, and has a large user base. It helps communities and is compatible with every browser (Chrome, Firefox, Internet Explorer, etc.). Besides, it also has a great platform compatibility (Windows, Mac OS, Linux etc.)

What is Selenese?

Ans. Selenese is the language used to write test scripts in Selenium IDE.

How many programming languages does Selenium support?

Ans. Selenium supports multiple programming languages like Java, C#, Ruby, Python, Pearl, etc.

What are the different Selenium components?

Ans. Different components of Selenium are sets of tools, which include:

– Selenium Integrated Development Environment (IDE)

– Selenium Remote Control (RC)

– Selenium WebDriver

– Selenium Grid

Elaborate the functioning of Selenium Grid?

Ans. Selenium Grid sends tests to the hub, which are then redirected to Selenium Webdriver. It then launches the browser and runs the test. The tests run in parallel with entire test suite.

Can we use Selenium grid for performance testing?

Ans. Yes, but it is not as effective as Loadrunner, which is a dedicated Performance Testing tool.

Which testing types are supported by Selenium?

Ans. Selenium supports two types of testing:

1. Functional Testing

2. Regression Testing

Also Read Top interview questions for QA Manager/Test Lead

How will you find an element using Selenium?

Ans. Every object or control in a web page is an element in Selenium, and some of the ways to find that element in a web page include using ID, Name, Tag, Attribute, CSS, Linktext, PartialLink Text and Xpath.

Check Selenium News here

What is Page Object Model (POM)?

Ans. POM is a design pattern responsible for creating an Object Repository for web UI elements.

What is Page Factory?

Ans. Page Factory provides an optimized way to implement Page Object Model and it has a very good memory utilization and implementation is object-oriented.

What is an XPath?

Ans. XPath is a language which helps to locate and process items in Extensible Markup Language (XML) documents. It addresses syntax based on a path through the document’s logical structure or hierarchy. XPath is used to locate a web element based on its XML path. It also stores, organizes and transports arbitrary data.

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

Ans. “/” or Single Slash creates Xpath from the document node/start node.

“//” or Double Slash creates Xpath with relative path from anywhere within the document.

Which test types are supported by Selenium?

Ans. So, Selenium supports –

– Functional Testing

– Regression Testing

– Sanity Testing

– Smoke Testing

– Responsive Testing

– Cross Browser Testing

– UI testing (black box)

– Integration Testing

What is the difference between type keys and type commands?

Ans. Type Keys trigger JavaScript event but the Type Command don’t. Type key simulates each keystroke using JavaScript, while whereas Type Command emulates actual user typing.

What is the difference between verify and assert commands?

Ans. Assert command helps to check the availability of a certain element on the page. The test terminates at the point the check fails, i.e. if the element is unavailable.

Verify command also helps to check the availability of a certain element on the page, but here the test goes on as all the commands run is guaranteed even if the check fails.

Can Selenium handle windows based pop up?

Ans. Since it is an automation testing tool and supports only web application testing, it can’t handle windows pop up. However, third-party tools like AutoITm and Robot class are available to handle this.

How do we handle web-based pop up in Selenium?

Ans. We can use WebDriver, which provides an efficient way to handle these pop-ups using Alert interface. Besides, there are four methods too that we can use –

void dismiss() – The accept() method clicks on the “Cancel” button when the pop-up window appears.

void accept() – The accept() method clicks on the “Ok” button when the pop-up window appears.

String getText() – The getText() method returns the text displayed on the alert box.

void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

Syntax:

// accepting javascript alert

Alert alert = driver.switchTo().alert();

alert.accept();

Tell me how can I take a screenshot in Selenium WebDriver?

Ans. You can do that by using the TakeScreenshot function and by using getScreenshotAs() method, you can save the screenshot.

Is it possible to enter a text without using sendKeys()?

Ans. Yes, we can enter/ send text using JavaScriptExecutor, and we don’t need to use sendKeys() method.

What is Junit?

Ans. It is a Java-based unit testing framework introduced by Apache.

What is Object Repository?

Ans. Object Repository refers to a collection of web elements belonging to Application Under Test (AUT) along with their locator values. Object Repository is used to store locators in a centralized location.

How can we create Object Repository in Selenium?

Ans. We can create Object Repository in an excel sheet that can be populated inside the script whenever required.

Does Selenium have any limitations?

Ans. Yes, it has.

– It supports testing of only web-based applications

– Can not test mobile applications

– Selenium can’t test Captcha and Barcode readers

– It helps to generate reports using third-party tools like TestNG or JUnit

– No ready vendor support

– User must possess programming language knowledge

google-news
Avinash

Avinash is the Founder of Software Testing Sapiens. He is a blogger and Software Tester who has been helping people to get thier Jobs over a years Now.

Leave a Comment

whatsapp-icon
0 Shares
Copy link