Selenium Interview Questions to Prepare in 2021

Selenium interview questions that you can expect will range from easy to advanced difficulty level. It is important that you fully familiarise yourself with the Selenium interview questions of different levels to ace your interview.

The interviewer, who is a Selenium Expert, never begins with simple questions like "What is Selenium?" or "Is it a free source?". If in case they inquire, that may serve as an icebreaker between you two. The true arrows are yet to be fired. So, hold on as it is going to be a ride - easy or thrilling, it depends on your preparation and the confidence level. Selenium interview questions that you can expect will range from easy to advanced difficulty level. It is important that you fully familiarise yourself with the Selenium interview questions of different levels to ace your interview.

Let us begin the most basic Selenium interview questions that you should prepare.

 

Basic Questions on Selenium

It is crucial to have the basics of Selenium interview questions cleared before the interview.

 

1. What precisely is Automation Testing?

Automation testing or Test Automation is the method of automating the human process of testing an application or system. Automation testing entails using a different testing method that allows you to generate test scripts that can be run continuously without human interaction.

Note: Selenium automation interview questions are quite. It would help if you focused on learning more about Selenium automation.


2. Discuss the features of Selenium 3.0.

Selenium 3.0 is the most recent version. It has launched two beta versions of Selenium 3.0, each with a few of the improvements mentioned below. Here are a couple of the latest features in Selenium 3.0:


Features of Beta 1

● The minimum Java version is 8+
● There is support for Firefox, Edge and Safari


Features of Beta 2

Beta 2 is only supported by Java.

● webdriver.gecko.driver can force the server in marionette or legacy firefox driver mode
● Grid fixes 
● Updated GeckoDriver – port argument in all bindings


3. Why and how can an Excel Sheet be included in your Selenium project?

We need Excel sheets to serve as a data source for tests. When running DataDriven Testing, an excel sheet could also be used to store the data set. The two primary reasons to use Excel sheets are:


a) When you use an excel sheet as a data source, you can save the following information:

● Application URL for all surroundings: You can determine the URL of the setting in which you choose to test, such as development, testing, or QA environments, staging environments, or production/pre-production environments.

● Credentials for user names and passwords: In the excel sheet, you can store the permission credentials for the various applications/environments. Instead of keeping them plain and vulnerable, you can store them in an encoded format and decrypt them anytime you want to use them.

● Test cases to be executed: You can mention the whole collection of test cases in one column and then specify Yes or No in the next column, indicating whether you want the specific test case to be executed or ignored.

b) When you use an excel sheet for DataDriven Test, you can save data for various iterations of the experiments. For instance, when checking a web page, the various sets of input data that must be forwarded to the test box may be saved in an excel sheet.


4. What is implied by Selenium Suite, and what are its components?

Since Selenium is a package of testing tools, it is also referred to as a Selenium Suite, with each tool built to meet a specific testing need. The following are the various Selenium Suite components:

● Integrated Development Environment (IDE) for Selenium: It is a Firefox/Chrome plugin designed to accelerate the development of automation scripts by logging user behavior in the web browser and exporting them as reusable scripts.

● Selenium Remote Control (RC): A server that allows users to create test scripts in the programming language of their choice. It takes commands from test scripts and delivers them to the browser as Selenium core JavaScript commands, causing the browser to act appropriately.

● Selenium Grid: It enables concurrent execution of tests on various browsers and operating systems by transmitting commands to several machines simultaneously.

● Selenium WebDriver: It is a programming interface that enables to create and run test cases by actively connecting with the web browser and using its native compatibility to automate. Unlike RC, it does not necessitate the use of a separate server to build and operate test cases.

Note: This one of the most important Selenium interview questions.


5. What is Selenium IDE?

Selenium IDE is a Firefox plugin that allows test scripts to be recorded and played back. Tests can export recorded scripts in various languages, including Java, Ruby, HTML, Python, C#, RSpec, JUnit, and TestNG. The reach of Selenium IDE is small, and the produced test scripts are not very reliable or portable.


6. What is a framework?

A framework is a collection of guidelines or standard practices that we should use to produce the intended outcomes in a structured manner. There are various forms of automation frameworks, the most famous of which are:

● Data-Driven Testing Framework 
● Keyword-Driven Testing Framework 
● Hybrid Testing Framework 
● Behaviour-Driven Framework


7. What are the various kinds of locators in Selenium?

A locator is a type of address that provides a specific method of defining a site feature on a webpage. Selenium has several locators for identifying various elements of a website, including:

● ClassName
● Name
● CSS Selector
● ID
● LinkText
● PartialLinkText
● TagName
● DOM
● XPath

 

8. What is the distinction between the Absolute and Relative Paths in Selenium?

Absolute Path: This path begins at the root node and concludes at the ideal element’s node.

It all begins with a simple dash (/).
For instance, /html.body/div/td/input

Relative Path: This path begins at every node in between and leads to the target element node.

It all starts with a double slash (/).
For instance, /input/example[@id=name]


9. What are the drawbacks of Selenium testing?

Some drawbacks of Selenium testing are:

● Unavailability of dependable technical support: Since Selenium is an open-source application, it does not provide dedicated technical resources to help users with their problems.

● Tests web apps only: Selenium must join hands with third-party platforms such as Appium and TestNG to monitor desktop and smartphone apps.

● Knowledge of programming languages might be required: Selenium WebDriver needs the user to have simple programming skills.

● There is no built-in reporting or test management capability: Selenium must come together with software such as TestNG or JUnit, among others, to promote test reporting and management.


10. What is Selenium XPath?

While the DOM is the recognized basic method for traversing an HTML entity tree, XPath is the navigation system used to find a site element based on the XML path.

XML stands for ‘Extensible Markup Language’, which is used to store, organize and transfer arbitrary data. It stores data in the form of a key-value pair, which is somewhat close to HTML tags. Since they are both markup languages and come under the same umbrella, XPath and HTML may be used to find elements.

The basic idea behind finding elements with XPath is to traverse through different elements through the entire page, allowing a user to locate an element by referencing another element.

Note: This one of the crucial Selenium interview questions.

 

Intermediate Interview Questions and Answers on Selenium

If you already know the basics of Selenium, the intermediate Selenium interview questions should be a piece of cake for you. However, you should still brush your memory from time to time to ace the interview.


1. What is the advantage of Python over Java in Selenium?

The advantages are as follows:

● Opposed to Python programs, Java programs always run slowly.
● Python programs are more lightweight and straightforward than Java programs.
● Python uses dynamic typing, while Java uses static typing.
● Python employs indentation, while Java employs standard braces to end and begin blocks.


2. How can we get the page source in Selenium?

We can get the page source in the selenium using driver.getPageSource(). This method returns a string containing the page's source code.


3. Create a code snippet in WebDriver to execute mouse hover.

The code snippet in WebDriver to execute mouse hover is as follows:
Actions action = newActions(driver);
WebElement element = driver.findElement(By.id("elementId"));
action.moveToElement(element).perform();


4. What is synchronization in Selenium? Explain in detail.

Synchronization is a process that requires two or more elements that function in tandem.

The two elements of Test Automation are the Application Under Test and the Test Automation tool.

Both of these elements have their own pace, and for them to move at the same and desired speed, we must compose our scripts in such a manner that we do not find "Element Not Found" errors, which waste time in debugging.

The two types of synchronization are unconditional and conditional synchronization.

 

● Unconditional Synchronisation: We just state the timeout value in unconditional synchronization. The tool will wait after a certain time has elapsed before proceeding.

Wait() and Thread are two examples.

The downside of the above statements is that, even though the application is ready, there is a possibility of an unnecessary waiting period.

It is unnecessary to write or scan for a state while interacting with third-party programs, such as interfaces. In such cases, we must make applications wait for a certain period by setting a timeout value, and the unconditional wait comes in handy.

 

● Conditional Synchronisation: We set a state and a timeout value in conditional synchronization, then the tool waits and scans for the condition, and then it exits if nothing occurs.

It is critical to set the timeout value in conditional synchronization so the tool can continue without waiting for a certain requirement to fulfil.

Explicit Wait and Implicit Wait are two elements of conditional statements in Selenium.

 


5. In Selenium, what do you mean by BreakPoints and Start Points?

Breakpoints are used to halt the execution of programming. They enable you to ensure that your code runs as intended. Start points denote the stage at which the execution will begin. It runs a test script from the centre of the code or from a breakpoint.

Note: This one of the vital Selenium interview questions.


6. What does the term "grouping" in TestNG mean in Selenium?

It is a unique TestNG function that did not occur in JUnit. You can delegate methods with appropriate meaning and optimize test method groupings.

Not only can you relate strategies to groups, but you can also instruct groups to incorporate other groups.


7. Can Selenium manage a windows-based pop-up, and if not, what are the alternatives?

Since Selenium is an automatic testing platform designed for web application-based testing, it does not allow windows-based pop-ups. On the other hand, Windows-based pop-ups can be managed in selenium with the help of third-party applications such as AutoIT, Robot class, and so on.


8. How do we use CSS Selector to pick elements based on their attribute values?

Using [attribute=value], we can pick all elements belonging to a specific class, for example, ‘[type=small]' can select all elements with the attribute type of value ‘small'.


9. What is Selenium Language Binding?

Language binding is a set of libraries that serve as a link between the Selenium WebDriver and a test script written in a specific language, allowing them to interact and understand each other.


10. What is the use of the Selenium AutoIt tool?

Some interruptions, such as a window-based pop-up, may get us stuck when experimenting with Selenium. However, since it only supports web-based applications, Selenium is unable to handle this.

To solve this problem, we need to use AutoIT in conjunction with a Selenium script. AutoIT is a third-party technology that manages window-based programs. VBScript is the scripting language used in AutoIt.

 

Advanced Interview Selenium Questions

Advanced Selenium interview questions need a candidate to have practical knowledge of Selenium.


1. What are the various kinds of Selenium frameworks?

Various kinds of frameworks are as follows:

Behaviour-driven development Selenium framework: The behaviour-driven development platform enables the automation of technical validations in a readily accessible and comprehensive format for Business Analysts, Developers, Testers, and others.

Module-based testing Selenium framework: This framework partitions the whole application under test (AUT) into logical and isolated modules. We write a different and independent test script for each module. As a result, when these test scripts are combined, it creates a bigger test script representing more than one module.

Keyword-driven testing Selenium framework: It is an evolution to the data-driven testing framework. It separates test data from scripts and stores a specific collection of test script codes in an external data file.

Data-driven testing Selenium framework: It allows one to separate the test script reasoning from the test data. It enables us to save the test results to an external archive. Traditionally, data is contained in ‘key–value' pairs. Inside the test scripts, keys are used to access and populate data.

Library architecture testing Selenium framework: Rather than splitting AUT into test scripts, this structure divides the application into functions and perhaps common functions that can be utilized for other sections of the application. As a result, we create a shared library of AUT-specific functions. These libraries may be named from the test scripts as required.

Hybrid testing Selenium framework: It is an amalgamation of more than one of the above-mentioned frameworks. The great thing about such a setup is that it takes advantage of the benefits of various associated frameworks.

Note: This one of the most critical Selenium interview questions.

 

2. Mention the different kinds of Selenium navigation commands.

Selenium has the following navigation commands:

● navigate().back(): Returns the consumer to the last or most recently accessed site page, based on the history.
● navigate().forward(): This moves the user to the next web page based on their browsing history.
● navigate().refresh(): This helps the user refresh the new site page by reloading all of the web elements.
● navigate().to(): Depending on the URL, redirects the user to a different site page in a new window.

 

3. What is a Selenium Robot class?

This Robot class is responsible for controlling the mouse and keyboard

KeyPress(): To press a key
KeyRelease(): Used to release a key that has been pushed on the keyboard
MouseMove(): Used to move the mouse pointer in the X and Y directions
MousePress(): Used to press the mouse's left button
MouseMove(): Assists in releasing the mouse's pressing button

 

4. Mention the difficulties in handling Ajax call in Selenium Webdriver.

The difficulties encountered when handling an Ajax call in Selenium Webdriver are as follows:

● Using the "pause" command to handle an Ajax call is not always reliable. Long pauses render the test unacceptably slow and lengthen the testing period. Instead, "waitforcondition" would be more useful in Ajax application testing.

● It is difficult to determine the probability of specific Ajax implementations.

● Giving developers complete freedom to change Ajax applications complicates the testing phase.

● It can be challenging for testing tools to create automatic test requests since AJAX applications often use various encoding or serialisation techniques to upload POST data.

 

5. What exactly is an Object Repository, and how can we build one in Selenium?

Object repository is the list of web elements associated with the program under test and their locator values. The main difference is that the locators are located in a single place rather than being hardcoded in the test scripts.

When it comes to Selenium, the objects can even be saved in Excel and used to populate them in the script as required.

Selenium advanced interview questions should be your utmost priority. Interviewers not only test your basic knowledge but also expect you to have a hold on the advanced side of it.

 

6. How do we obtain the text of a web element?

The get command is used to extract the inner text of a web element. The command takes no parameters and returns a string value. It is also one of the most commonly used commands for verifying notifications, labels, bugs, and other information shown on web pages.

Syntax:
String Text = driver.

findElement(By.id(“Text”)).

getText();

 

7. What is the distinction between the Selenium commands driver.close() and driver.quit()?

The driver.close() command removes the currently active window in which the user is operating or the window being used by the site administrator while the driver.quit() command eliminates all windows accessible by the application and can therefore be used with caution.

Both commands do not accept any parameters and do not return any values.

 

8. What exactly do you mean by "Same Origin Policy"? How to handle it?

An Origin is a sequential combination of the URL's host, scheme, and port. The same-origin protocol problem prevents a user from accessing the DOM of a database from a separate origin than the one from which the user is attempting to access the document.

The Selenium Core is not permitted to use elements from a source other than the one from which it was launched. To address the issue of the Same Origin Policy, Selenium Remote Control was adopted.

Note: This one of the most important Selenium interview questions.

 

9. What's the distinction between driver.get() and driver.navigate.to("url")?

driver.get(): To open a URL and wait for the whole website to load
driver.navigate.to(): To navigate to a URL without having to wait for the whole website to load

 

10. What is the difference between the commands "type" and "typeAndWait"?

The "type" command is used to enter keyboard key values into the program site application's text box. It may also be used to pick values from a combination box, while the "typeAndWait" command is used until your typing is finished and the program site page begins to reload. This order will wait for the page of the software application to restart. If no page reload event occurs while typing, you must use a basic "type" command.

Selenium questions asked in the interview include topics like Cucumber, Appium, etc. We’ve covered them below for your reference.

 

Interview Questions on Selenium for Experienced based on Cucumber

Apart from knowing the basic, intermediate, and advanced Selenium interview questions you should also know a little about Cucumber as it may be asked in the interview.

 

1. Explain Cucumber shortly.

Cucumber is a tool that is premised on Behaviour Driven Development (BDD) methodology.

The behaviour-driven development framework's key goal is to help different project roles, such as Business Analysts, Quality Assurance, Developers, and so on, grasp the application without delving too far into the technological aspects.

 

2. What is the distinction between Jbehave and Cucumber?

While Cucumber and Jbehave are both intended for the same purpose, acceptance tests are handled by entirely different frameworks. Jbehave is a Java-based system, while Cucumber is a Ruby-based framework.

Cucumber is built on functionality, while Jbehave is based on stories.

 

3. What prerequisites must be met before developing a Selenium Cucumber automation framework?

When developing a productive and flexible test framework, you can keep the following points in mind.

● Determine the form of application to be tested. Is it a Web app, does it help handheld devices, or does it operate on a desktop?

● Would it necessitate downstream testing? Databases, for example, or software development kits (SDK).

● It must provide a summary that will assist you in tracing a mistake with minimal effort.

● It must be able to generate parameterisation tests automatically.

● Maintain a configuration file to specify some setup-related configurations or global resources.

● Use abstraction at all levels to isolate features.

 

4. Explain test harness.

A Cucumber and RSpec test harness separate liability for setting up the context, interacting with the browser, and cleaning up the step definition files.

 

5. Is it possible to find ready-made Selenium-Cucumber frameworks?

Yes, there are a couple of ready-made Selenium Cucumber frameworks, they are listed below:

● Selenium-Cucumber framework for web and Android app testing
● Another is a framework for acceptance testing that employs Cucumber and Selenium Webdriver.

 

6. What is indicated by a feature file?

A feature file should include a high-level overview of an Application Under Test (AUT). The feature file's first line must begin with the keyword 'Feature,' accompanied by a summary of the application under test.

Within the same file, a feature file can contain several scenarios. The extension of a feature file is .feature.

 

7. What is a cucumber profile?

Cucumber profiles are used to operate a series of features and step definitions. To run a cucumber profile, type the following instruction:

cucumber features -p <profile_name>

#Example: cucumber features -p acceptance

 

8. What is the intention of a Cucumber Scenario Outline?

A scenario outline is a method of parameterising scenarios. This is useful because the same scenario must be run with different sets of data, but the test steps stay the same. The keyword ‘Examples' must be supplemented by Scenario Outline, which specifies the set of values for every parameter.

 

9. Why combine Cucumber and Selenium?

Two common technologies are cucumber and selenium. Selenium is widely used in organizations for functional testing. These Selenium-using companies choose to combine Cucumber with Selenium because Cucumber lets you interpret and comprehend the application flow.

 

10. What is a step definition?

The Test Case Steps in the feature files are mapped to code by step definition. It runs the measures on the Application Under Test and compares the effects to the predicted ones. It must fit the given component in a function to implement step definition.

 

Selenium Appium Questions

Besides knowing the basic, intermediate, and advanced Selenium interview questions, you should also know a little about Appium as it may be asked in the interview.

 

1. What's the difference between a simulator and an emulator?

Emulation is the act of imitating an existing target's outwardly visible actions. The emulation mechanism's internal state does not have to correctly represent the inner state of the object it is emulating.

Simulation entails replicating the target's underlying state. A successful simulation would result in the simulation model emulating the goal that it is simulating.

In an ideal world, you must be able to examine the simulation and see properties that you might still see if you examined the original target. There are certain performance-related alternatives to the simulation — that is, some internal elements of the simulation can simply be emulation.

 

2. What is Appium, and what is the need for it?

Appium is a free mobile testing platform that is open-source and accessible on GitHub. Its fast integration with Selenium Webdriver is what makes it famous.

It will entirely depend on your needs. But first and foremost, you must grasp what you can use Appium for. For instance, whether you are a developer or a mobile app tester who wishes to evaluate your app through several platforms, Appium will assist you in this pursuit.

On the other hand, if the app is just for a specific platform, it is not worth the time and effort to understand and use Appium for test automation.

 

3. What are the fundamental requirements for writing Appium tests?

For writing Appium tests, the following are required:

● Driver Client: Appium's Driver Client drives mobile applications as if they were a user. Appium tests are written using a client library, which wraps the test steps and sends them to the Appium server using HTTP.

● Appium Session: You must first create a session and then run the Appium test inside it. Once the automation for one session is done, it can be terminated and re-started for the next session.

● Desired Capabilities: To start an Appium session, you must specify those parameters known as "desired capabilities," such as PlatformName, PlatformVersion, Device Name, and so on. It determines the level of automation that the Appium server must-have.

● Driver Commands: You can use a broad and descriptive vocabulary of commands to compose the test steps.

 

4. Do you require a server machine to run Appium tests?

No, you do not require a server machine to run Appium tests. Appium enables a two-tier system in which a test machine links to a test server operating Appium and automates the whole process. Appium can be installed on the same machine as the test.

 

5. Do you like testing on real devices or using simulators/emulators?

It's one of the most often seen Selenium interview questions based on Appium. You must be rational and realistic in your answer. Don't just say, "That will rely on what you like” as that would be a layman's answer, which the interviewer would not expect from you. Instead, use an illustration to demonstrate the point.

You might claim something along the lines of "it's still best to try on actual computers." As a result, you would be able to spot errors that you might not have been able to detect otherwise. However, you must configure the system intelligently with the Appium registry so that it can be detected. Even if the computer is plugged in, the ADB, the Android debugger, can detach from it at times. It can also trigger the exams to fail. To address certain problems, you should write a plugin that resets the ADB after a certain time to reconnect the devices.

 

6. What do you think is Appium's strongest suit?

Appium is built on Selenium, a Google HTTP protocol designed to simplify browsers. The concept is actually very appealing, as automating an app (particularly a web view-based one) is not that dissimilar (in terms of necessary APIs) to automating a browser.

Appium is often intended to promote a two-tier architecture: one machine runs the test written in one language (C#, Ruby, and JavaScript are only a couple of the several supported languages), and another (the test server) actually executes it. Furthermore, since the WebDriver protocol is built on HTTP, Appium is quite scalable; keep in mind that you will just need to write the test once, and Appium will be in control of executing it on multiple platforms.

 

7. What really is the Appium philosophy?

These are the four philosophies around which Appium is built:

● Test the same app that you want to send to the marketplace.
● Create your tests in any and every language and framework.
● Make use of a standardized automation specification and API.
● Create a massive and vibrant open-source community.

 

8. How long would it take to create an Appium test?

Of course, this is dependent on the test. If the test simply runs a case, it would include as many commands as the number of interactions required (thus very few lines). If you attempt to share results, the test would undoubtedly take longer and become more difficult to read.

 

9. What exactly is Appium inspector and why should it be used?

It is identical to the Selenium IDE plugin in that it allows Appium's record and replay support. It inspects the DOM to catch the movements of a native application and generates test scripts in either language. Appium Inspector, on the other hand, does not support Windows and instead employs the UIAutomator> viewer as an alternative.

 

10. Can we run an Appium test in a multithreaded environment?

Yes, we can run the test in a multi-threaded setting, but we must verify that no more than one test runs against the same Appium server at the same time.


Conclusion

Since businesses are progressively relying on online technologies, test automation industry dynamics are rapidly rising, with Selenium in high demand. Furthermore, by growing the number of testing cycles, Selenium allows practical testing quicker and more comfortable for clients, allowing them to collect ROI even sooner. You are already on the correct path of growth and with these Selenium interview questions listed above, you are sure to crack any Selenium interview with even the most complex of Selenium questions. All the best!

 

Author Bio:

Hina Murdhani, QA Engineer, SCIKEY

SCIKEY     LinkedIn

Hina is a QA engineer at SCIKEY with 2.5 years of experience in automation as well as manual testing. She loves to find the bugs to break the system and likes to grab the opportunities to learn new technologies. Besides that, she is an artist, writer, and nature lover.


Hina Murdhani

1 Blog posts

 Comments