Selenium Automation
30+ Selenium Automation Interview Questions and Answers

Asked in Wipro

Q. Write a program to remove duplicate character in a string if there are multiple users in an application, and if the buttons in the applications are specific to particular user, you need to perform operation in...
read moreQuestions related to Selenium Automation and software testing
To remove duplicate characters in a string, use a loop and a hashset
To perform operations on specific buttons for a user, use conditional statements
To switch to a particular tab, use the window handle
500 error code in Postman validation indicates a bad request
Primary key is a unique identifier for a record in a database
Roles and responsibilities in a project depend on the project and team

Asked in Wipro

Q. If a page has two login buttons, will they have the same ID?
No, the two login buttons should not have the same ID.
IDs should be unique for each element on a page
Having two elements with the same ID can cause issues with locating and interacting with the elements

Asked in Wipro

Q. How will you retrieve all the values from the drop down?
To retrieve all values from a drop down, we can use the getOptions() method and store the values in an array of strings.
Locate the drop down element using any of the locators
Create a Select class object by passing the drop down element as a parameter
Use the getOptions() method to retrieve all the options from the drop down
Store the options in an array of strings

Asked in Wipro

Q. How do you write the step execution report/result in the report?
Use TestNG or JUnit framework to generate step execution report/result.
Use TestNG or JUnit annotations to mark the start and end of each test step.
Use TestNG or JUnit listeners to capture the test results and generate the report.
Use reporting libraries like ExtentReports or ReportNG to generate detailed reports with screenshots and logs.

Asked in Ness Digital Engineering

Q. How do you execute a feature file in parallel in a BDD Cucumber Framework?
To execute feature files in parallel in BDD Cucumber Framework, we can use tools like Maven Surefire plugin or Cucumber-JVM-Parallel-Plugin.
Use Maven Surefire plugin to run tests in parallel by adding
and tags in pom.xml file Use Cucumber-JVM-Parallel-Plugin to run tests in parallel by adding @CucumberOptions(plugin = {"json:target/cucumber-report/cucumber.json", "com.github.temyers:cucumber-jvm-parallel-plugin:5.0.0"}, threads = 3) annotation in the runner class
Ensure that ...read more

Asked in Wipro

Q. How do you switch to the second window using the page title?
To switch to the second window using page title, we can use getWindowHandles() and switchTo() methods.
Use getWindowHandles() method to get all the window handles
Iterate through the window handles and switch to the desired window using switchTo() method
Use getTitle() method to get the title of each window and compare it with the desired title
Selenium Automation Jobs




Asked in Accenture

Q. Types of xpaths, project structure, cucumber dry run option, testing basic annotations, difference between interface and abstract class, what are the concepts of oops
Answering questions related to Selenium Automation
Types of xpaths: Absolute and Relative
Project structure: Follows a modular approach
Cucumber dry run option: Used to check feature file syntax
Testing basic annotations: @Test, @BeforeTest, @AfterTest
Difference between interface and abstract class: Interface has only method declarations, abstract class has both method declarations and implementations
Concepts of OOPS: Inheritance, Polymorphism, Encapsulation, Abstraction

Asked in Ness Digital Engineering

Q. How do you handle multiple popups in Selenium?
To handle multiple popups in Selenium, we can use getWindowHandles() and switchTo() methods.
Use getWindowHandles() method to get all the window handles
Switch to the desired window using switchTo() method
Perform actions on the popup window
Switch back to the main window using switchTo() method
Share interview questions and help millions of jobseekers 🌟

Asked in Ness Digital Engineering

Q. How do you retrieve all options from a dropdown menu?
To get all options in a dropdown, use the getOptions() method and store the values in an array of strings.
Locate the dropdown element using any of the locators
Create a Select class object by passing the dropdown element as a parameter
Use the getOptions() method to get all the options in the dropdown
Store the options in an array of strings

Asked in Wipro

Q. What collections are used in the framework?
Collections like ArrayList, HashMap, HashSet are commonly used in Selenium framework.
ArrayList is used to store a list of elements
HashMap is used to store key-value pairs
HashSet is used to store unique elements
Collections class is used for sorting and searching

Asked in Accenture

Q. What is the mother of all classes?
There is no such thing as 'mother of all classes' in Selenium Automation.
There is no concept of 'mother of all classes' in Selenium Automation.
It is possible that the interviewer is asking a trick question or trying to test the candidate's knowledge.
The candidate should politely ask for clarification or context before attempting to answer.
If the interviewer insists on an answer, the candidate can explain that there is no such thing and provide examples of important classes in...read more

Asked in Wipro

Q. What is the difference between a simple Java program and a Maven project?
A simple Java program is a standalone program while a Maven project is a build automation tool.
A simple Java program is compiled and executed using the command line or an IDE.
A Maven project uses a pom.xml file to manage dependencies and build the project.
A simple Java program may require manual management of dependencies.
A Maven project can easily manage dependencies and build the project with a single command.
A simple Java program may not have a defined project structure.
A ...read more

Asked in Ness Digital Engineering

Q. How do you send credentials via URL?
Credentials can be sent via URL by appending them to the URL as query parameters.
Append the username and password as query parameters to the URL
Encode the username and password using Base64 encoding
Example: http://example.com/login?username=admin&password=encoded_password

Asked in Ness Digital Engineering

Q. How do you scroll a page to a desired location?
To scroll page to desired location, use JavaScriptExecutor and scrollTo() method.
Create an instance of JavaScriptExecutor
Use executeScript() method to execute scrollTo() method
Pass the desired location as arguments to scrollTo() method
Example: ((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");

Asked in Ness Digital Engineering

Q. What is the difference between Explicit wait and Fluent Wait?
Explicit wait waits for a specific condition while Fluent wait waits for a condition with polling interval.
Explicit wait waits for a specific condition to occur before proceeding further
Fluent wait waits for a condition with a polling interval and ignores exceptions
Explicit wait is used when we know the condition and the maximum time to wait for it
Fluent wait is used when we don't know the maximum time to wait for a condition
Example of explicit wait: WebDriverWait wait = new ...read more

Asked in Ness Digital Engineering

Q. How do you initialize a Chrome driver?
To initialize Chrome driver, create an instance of ChromeDriver class.
Create an instance of ChromeDriver class
Set the path of ChromeDriver executable file
Use the instance to interact with the browser

Asked in AlphaSense

Q. What is webdriver and webelement
WebDriver is a tool for automating web applications. WebElement is an interface representing an HTML element.
WebDriver is a browser automation tool used to control the browser and interact with web elements
WebElement is an interface representing an HTML element on a web page
WebDriver interacts with web elements using the WebElement interface
Examples of web elements include buttons, text fields, and links

Asked in Wipro

Q. Why are tags used in Cucumber?
Tags are used in Cucumber to organize and filter scenarios and features.
Tags allow for easy organization of scenarios and features based on their purpose or functionality.
Tags can be used to filter which scenarios or features are run during a test.
Tags can be added to scenarios or features using the '@' symbol followed by the tag name.
Tags can also be used to pass parameters to step definitions.
Examples: @smoke, @regression, @login, @api, etc.

Asked in TCS

Q. What are constructors?
Constructors are special methods that are used to initialize objects in a class.
Constructors have the same name as the class.
They are called automatically when an object is created.
They can be used to set default values for object properties.
Constructors can be overloaded to accept different parameters.
Example: public class Car { public Car() { // constructor code here } }

Asked in Wipro

Q. How do you disable a test?
To disable a test, we can comment out the test code or use testNG annotations.
Comment out the test code
Use testNG annotations like @Test(enabled=false)
Use testNG XML file to disable the test
Use groups to disable a set of tests

Asked in Wipro

Q. What are the key differences between TestNG and JUnit?
TestNG is more advanced and flexible than JUnit, with features like parallel testing and data-driven testing.
TestNG supports parallel testing while JUnit does not.
TestNG allows for data-driven testing while JUnit does not.
TestNG has more advanced annotations and reporting features than JUnit.
TestNG can be used with both Java and non-Java languages while JUnit is only for Java.
JUnit is simpler and easier to learn than TestNG.

Asked in Polaris Consulting

Q. What is the super interface in WebDriver?
A super interface in Selenium WebDriver is an interface that extends multiple interfaces.
A super interface allows a class to inherit methods and variables from multiple interfaces.
It provides a way to achieve multiple inheritance in Java.
For example, the WebDriver interface is a super interface that extends multiple interfaces like SearchContext and TakesScreenshot.

Asked in AlphaSense

Q. Expected conditions in selenium
Expected conditions are pre-defined conditions that can be used to wait for a certain state or element in Selenium.
ExpectedConditions.elementToBeClickable() - waits for an element to be clickable
ExpectedConditions.visibilityOfElementLocated() - waits for an element to be visible
ExpectedConditions.titleContains() - waits for the page title to contain a certain text

Asked in Polaris Consulting

Q. What reporting tools are available in Selenium WebDriver?
There are several reporting tools available for Selenium WebDriver.
TestNG
JUnit
ExtentReports
Allure Reports
Custom reporting using log4j or Apache log4j
Asked in Functionize Software

Q. What are the different types of locators in Selenium?
Locators are used in Selenium Automation to identify elements on a web page.
ID Locator: Uses the 'id' attribute of an element
Name Locator: Uses the 'name' attribute of an element
Class Name Locator: Uses the 'class' attribute of an element
Tag Name Locator: Uses the HTML tag name of an element
Link Text Locator: Uses the text of a link element
Partial Link Text Locator: Uses a partial text of a link element
CSS Selector Locator: Uses CSS selectors to identify elements
XPath Locator...read more

Asked in AlphaSense

Q. How do you wait for a file to load using Selenium?
To wait for file loading in Selenium Automation, we can use explicit wait or thread.sleep() method.
Explicit wait is used to wait for a specific condition to occur before proceeding with the next step.
Thread.sleep() method is used to pause the execution for a specified amount of time.
We can also use the ExpectedConditions class to wait for a file to be loaded.
Waiting for a file to be loaded is important to ensure that the file is available for further processing.

Asked in Accenture

Q. How do you handle multiple windows in Selenium?
Multi-window handling in Selenium involves managing multiple browser windows or tabs during automation testing.
Use driver.getWindowHandles() to get all window handles.
Switch to a specific window using driver.switchTo().window(windowHandle).
To close a window, use driver.close() and switch back to the original window.
Example: After opening a new tab, switch back to the main window using driver.switchTo().window(originalWindowHandle).

Asked in Wipro

Q. How does priority work in TestNG?
Priority in TestNG determines the order in which test methods are executed.
Priority can be set using the 'priority' attribute in @Test annotation
Default priority is 0, higher priority is executed first
Priority can be negative as well
If two methods have the same priority, they are executed in alphabetical order

Asked in Infosys

Q. What are the different types of waits in Selenium?
Waits are used to synchronize the test execution with the application's response.
Implicit Wait
Explicit Wait
Fluent Wait
Thread.sleep()
WebDriverWait

Asked in Innovaccer

Q. What are the different types of waits available in Selenium?
Selenium waits are crucial for handling dynamic web elements during automation testing.
Implicit Wait: Sets a default wait time for the entire session. Example: driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Explicit Wait: Waits for a specific condition to occur before proceeding. Example: WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.visibilityOf(element));
Fluent Wait: Similar to explicit wait but allows polling at regular ...read more
Interview Experiences of Popular Companies





Top Interview Questions for Selenium Automation Related Skills



Reviews
Interviews
Salaries
Users

