Selenium Interview Questions

Selenium Interview Questions: Selenium is a popular open-source automation testing tool for testing web applications across different browsers and platforms. It offers a wide range of features and capabilities, making it a go-to choice for many software testing professionals. As Selenium’s popularity grows, so does the need for experienced Selenium testers.

To ensure that you have the necessary skills and knowledge to excel in a Selenium testing role, it’s crucial to prepare for interviews by reviewing commonly asked Selenium interview questions. This way, you can demonstrate your expertise and stand out from other candidates in the highly competitive job market. This article will provide an overview of some of the most commonly asked Selenium interview questions and offer insights into how best to answer them.

Selenium Interview Questions

Here we are to share some of the top Selenium interview questions, which will help you extend your knowledge of Selenium. As you can see, where you are trying to cover most asked Selenium interview questions in an interview point, it should be better if you decide to answer all of these Selenium interview questions.

  • Difference between maven test and install
  • In your framework, what is called the first
  • Drop down handling
  • Maven cycle
  • What happens when we call MVN clean
  • TestNG parallel
  • TestNG priority
  • Data provider working
  • Working on ArrayList
  • What is the use of Thread count?
  • If I have not provided an XML suit file in Surefire, then what kind of exception will it throw
  • Stale element exception
  • Invalid argument exception
  • Difference between no such element found exception and Stale element exception.
  • What kind of exception have you faced in selenium?
  • What is automation testing?
  • What are the types of automation testing?
  • Whatโ€™s the difference between manual testing and automated testing?
  • When is a good time to automate a test?
  • When will you avoid automated testing?
  • How do you choose a tool/framework for automated testing?
  • What are the different parts of a test automation framework?
  • Should you automate all testing?
  • What is a test environment?
  • What is browser automation?
  • What is cross-browser testing?
  • Why do you need cross-browser testing?
  • What is automated regression testing?
  • What are some of the best practices in test automation?
  • What is the test automation pyramid?
  • Is automated testing making manual testing obsolete?
  • Who should be responsible for test automation? Developers or the QA?
  • What is Selenium? What are its pros and cons?
  • What are the different components of Selenium?
  • What is UI testing?
  • What is Protractor?
  • What is a test automation platform?
  • What are some of the alternatives to Selenium?
  • What is the Robot framework? Provide a brief overview of its architecture.
  • What are the test library APIs provided by the Robot Framework?
  • How will you automate the basic login in a web application?
  • What are some risks associated with automated testing?
  • What are the different phases in an automation testing life cycle?
  • What is CAPTCHA?
  • How do you automate the testing of CAPTCHA?
  • What are some development practices to follow when writing automated tests?
  • When selecting an automation tool, what features will you look for

Selenium Advanced Interview Questions

  • Actions in Selenium
  • Write positive and negative scenarios for Alerts
  • The syntax for Windows handler
  • Find odd number
  • Disadvantages of Selenium
  • Diff between get() and navigate().to()
  • Dynamic Table with the check box
  • Write the code for the Screenshot
  • Explain Maps in Java
  • Explain your project framework
  • What is Pom.xml
  • Tell the correct Xpath
  • Xpath methods
  • Explain the CSS selector
  • How to identify dynamic images
  • Print only integers from strings
  • Remove duplicates from ArrayList.
  • Print the frame names
  • How to read from XML or CSV file and store in hashmap
  • Get the value of a cell in the Dynamic table.
  • Burndown chart(Agile)
  • Print these characters from a given string and change them to uppercase.
  • Access specifiers in Java
  • Difference between Priority and Severity
  • Example for High Priority and Low Severity and vice versa
  • Difference between Test Strategy and Test Scenario
  • What are Software Metrics
  • How to handle Dynamic Elements, since the webpage is designed in Angular JS
  • Implicit and Explicit Waits
  • Cross Browser Testing
  • Method Overloading and Method Overriding
  • Static Method
  • Dependencies in Pom.xml
  • Write code for fetching data from Excel
  • Select Statement
  • Assert and Verify
  • Check if a string is Palindrome or not.
  • Remove duplicate characters from a string and print
  • Which Code Repository are you using(Ex: GitHub)
  • How will you estimate the time to automate a scenario
  • Right Click
  • In a dynamic Table, if I give one cell value, it should give me the values of other cells in that row.
  • Have you developed any Tools? If yes, explain
  • Frames
  • Read from a text file and store it in HashMap.
  • Print the occurrence of a character if it is present more than once in a string.
  • Write code for nested drop-down, and You have to check all the values in the dropdown.
  • Advantages of Selenium
  • Try Catch
  • How to check if a checkbox is displayed
  • What exceptions have you faced
  • What difficulties have you faced in Selenium
  • What all TestNG Annotations used in the project
  • Where will you maintain the code?
  • What are Explicit wait and Implicit wait?
  • What is a headless browser?
  • How to get a screenshot in Selenium? Can you write the syntax?
  • What are the different types of Locators in Selenium?
  • What is the best way to locate a web element without a unique XPath?
  • What is StaleElementReferenceException? Have you ever encountered it, and how do you handle it?
  • Do you run test cases parallel to TestNG? If yes, how many threads, and does it cause any problems?
  • What is the most common locator you use in your project?
  • Have you ever done the profiling of a web page?
  • How frequently do you use Thread.Sleep()?
  • Suppose there are two elements on a web page with the same IDs. How will you handle it?
  • Can we create an object for an interface?
  • What is the difference between @BeforeTest and @BeforeMethod in TestNG?
  • How does Selenium interact with the Web browser?
  • Can you make the constructor of a class static?
  • How do you maintain your test scripts, and how frequently do you modify them?
  • How to find all broken links on a webpage?
  • Explain your Automation Framework.
  • Write a dynamic XPath to locate a table’s 2nd-row 3rd-column data.
  • Hash map vs. Hash table.
  • What is the significance of a hash table?
  • What is the return type of findElements?
  • Whatโ€™s the difference between a Maven project and a Java project?
  • Getwindowhandle vs Getwindowhandles and the return types.
  • Comparable vs comparator.
  • Explain the project along with how the Automation was done.
  • How to upload a file in Selenium?
  • How to upload a file without using Sendkeys?
  • How to connect to a Database using Selenium?
  • Any idea or experience with the Continuous Integration tool?
  • How to handle a drop-down in Selenium?
  • What is WebDriver โ€“ interface?
  • Why do we need an Interface in a test?
  • How to integrate your test with Jenkins?
  • Any example or practical usage of Run time polymorphism?
  • How to find dynamic elements?
  • What is the difference between CSS selector and XPath? Which is better from a performance perspective?
  • Difference between Instantiate and Initialize in Java.
  • What is meant by fluent wait?
  • What kind of framework have you made?
  • Whatโ€™s TestNG Listener Class & why do we use it?
  • Any idea about Selenium Grid? Or Parallel execution.
  • What are the challenges you face when running automation scripts?
  • Difference between == and =.
  • Whatโ€™s Page Factory?
  • How do you click a button without using click() and CSS & XPath selectors?
  • Are multiple inheritances possible in Java? Why?
  • Are all methods in an abstract class abstract?
  • Can we make an Object of Abstract class or an Interface?
  • Whatโ€™s the difference between method overloading and overriding?
  • Whatโ€™s the use of the Java Static keyword?
  • Different types of polymorphism.
  • Can we write webdriver dr = new webdriver();
  • What are the different plugins used for Maven? And its use?
  • What is the difference between Abstract and Interface?
  • Try, Throw & Catch syntax. And why is it used?
  • How do you manage to re-run only failed test cases?
  • How to make TestNG.xml at run-time?
  • Whatโ€™s Singleton’s class?
  • Can we have the Finally block without Try & catch blocks?
  • Use of Super and This keyword in Java.
  • Whatโ€™s Data binding?
  • Whatโ€™s the difference between Final, Finally, and Finalize?
  • What is the difference between Absolute and Relative XPath? Which is faster?
  • How to execute the Java program from the command prompt?
  • What is Continuous Integration?
  • What is the return type of DataProvider?
  • Whatโ€™s Maven’s Life cycle?
  • Whatโ€™s the difference between plug-ins and dependencies?
  • How to make a class immutable?
  • What do you mean by automation testing or test automation?
  • Are there any benefits of automation testing over manual testing?
  • Selenium is a single testing tool, so why is it taken as a suite by professionals?
  • What are selenium-supporting testing types?
  • Are there any drawbacks to the selenium testing tool?
  • What do you understand by the term โ€œSeleneseโ€?
  • How to identify web elements in Selenium?
  • Explain the meaning of XPath in Selenium.
  • How to count the number of elements on a page?
  • Can you name the popular selenium tool used by large industries worldwide?
  • Explain the waiting methods in Selenium Web Driver.
  • Where the implicit waiting method and explicit waiting method can be used in your script?
  • Is there any technique to check whether either button is enabled on the page or not?
  • Is there any technique to check whether a particular element is visible on the page or not?
  • Name the different types of drivers available in Web Driver.
  • Name the different types of mobile testing drivers supported in Web Driver.
  • Name the programming languages that are used by Web Driver to write the test cases.
  • Do you know the difference between assert commands and verifying commands in Selenium Web Driver?
  • Explain the difference between”/” and “//”in XPath Selenium WebDriver.
  • Name the different types of annotations used in Selenium WebDriver.
  • Which selenium technology is useful for distributed data processing?
  • How will you check the result of text execution in Selenium IDE?
  • How can you modify test cases in Selenium IDE?
  • Explain the significance of JUnit in the Selenium testing tool.
  • How to add meta-data in the JUnit selenium testing tool?
  • How will you explain the difference between quit () and close () methods in Selenium?
  • Why was the concept of the waiting method introduced in Selenium? Name the type of waits in Selenium.
  • Is there any drawback to implementing implicit waits in Selenium?
  • Why do Selenium tools fail sometimes?
  • Name the four parameters that have to be passed in Selenium.
  • How to handle an Authentication Pop-up using Selenium WebDriver?
  • The Selenium script runs in Chrome but not in IE. What can be done?
  • What is the difference between ChromeOptions and Desired Capabilities?
  • Is it possible to do responsive web design testing using Selenium?
  • What is the need for database automation testing? Is it possible to perform database testing with Selenium?
  • Why are assertions important in Selenium? What are the different types of assertions?
  • What is a data-driven framework? How does the data Provider help in data-driven testing

Latest Selenium Interview Questions

  • Give an example of abstraction(writing program)
  • How many test cases have you written and automated?
  • What are the challenges you met while automating?
  • How will you handle the drop-down list?
  • How will you Download the popup?
  • What are the different browsers you have used
  • What are the settings to be used for IE Chrome and Firefox browsers?
  • What’s Overloading and overriding in difference
  • How do you use selenium IDE
  • Three versions of selenium and drawbacks
  • In Eclipse, while automating how will b the file structure of your scripts
  • Explain your selenium profile
  • What is the difference between a data-driven and hybrid framework?
  • What is a hybrid framework?
  • Which framework have you used in your project?
  • Where do you add a test case?
  • What is // and /slash?
  • What are the challenges you have faced in your project?
  • What is XPath
  • Which selenium version are you working
  • How do you find the XPath
  • What is a regular expression?
  • How do you connect the database through selenium?
  • How do you connect the database through Java?
  • Difference between verify and assert
  • Tell me about yourself
  • What is SDLC
  • Explain selenium architecture in your company
  • What is Selenium IDE
  • What is Selenium RC
  • What is Selenium Webdriver
  • Difference between RC and Webdriver
  • Write a program to reverse a string in Java
  • Write an SQL query to list the first ten rows in two columns empname and salary.
  • What is Bug lifecycle?
  • What is the final method in Java?
  • What do you call a function in Java?
  • What kind of framework do you use?
  • What is JUnit, and how do you read data from Xls
  • Have you used TestNG?
  • How do you work on selenium?
  • How do you handle popups?
  • How do you handle the HTTPS website in Selenium?
  • What is agile
  • What is sprint
  • How do you get the requirements?
  • How do you write functional test cases based on requirements?
  • How do you start a selenium server?
  • How do you download and use selenium?
  • What problems did you face with selenium?
  • How do you identify an element in Xpath?
  • What is the use of Xpath?
  • How much do you rate yourself in Java and SQL?
  • The aptitude test booklet consisted of 15 pages and 29 questions, and the few questions had five sub-questions, and the time limit was 1 hour.
  • Different types of locators?
  • Selenium Framework that you are using in your current project?
  • How do you identify the Xpath of an element on your browser?
  • Selenium function used for retrieving the attribute or value?
  • How do you differentiate checkboxes if multiple checkboxes exist in your application?
  • What is the difference between Assert and Verify?
  • Explain SDLC & STLC.
  • What is the alternate way to click on the login button?
  • How do you verify if the checkbox/radio is checked or not
  • How do you get the href of a link / get the source of an image?
  • Count the number of links on a page
  • How to check all checkboxes on a page.
  • What is the output of the below code? driver.findElements(By.tagName(“img”));
  • How do you handle browser popups?
  • How do you handle elements present inside the frame?
  • How do you handle the Javascript alert/confirmation popups?
  • How do you launch the IE/chrome browser?
  • How to perform right-click using WebDriver?
  • How do we perform drag and drop using WebDriver?
  • How to send ENTER/TAB keys in WebDriver?
  • Example of method overload in WebDriver
  • How do you upload a file?
  • How do you click on a menu item in a drop-down menu?
  • How do you work with a page onload authentication popup/windows-based popup?
  • How do you simulate the browser back and forward?
  • How do you get the current page URL?
  • What is an XPath?
  • What is the difference between โ€˜/โ€™ and โ€˜//.โ€™
  • What is the difference between findElement and findElements?
  • How do you achieve synchronization in WebDriver?
  • Explain implicit and explicit wait.
  • How do you handle untrusted certificates?
  • Write the code for Reading and Writing to Excel through Selenium
  • How do you get the typed text from a textbox?
  • What are the different exceptions you get when working with WebDriver?
    InvalidSwitchToTargetException [The frame or window target to be switched doesnโ€™t exist.]
    NoSuchElementException
    NoSuchFrameException
    TimeoutException
    SessionNotFoundException
  • What is the current WebDriver version?
  • What is WebDriver
  • Explain the challenges you faced in automation
  • What are the languages supported by WebDriver?
  • What is the difference between verify and assert?
  • What are the limitations of Selenium IDE?
  • What are the browsers supported by Selenium IDE?
  • What are the disadvantages of Selenium?
  • How many ways can you identify an element using WebDriver? Which are the locators used for recognizing the objects in Selenium WebDriver?
  • How do you clear the contents of a textbox in selenium?
  • Is it possible to interact with hidden elements using WebDriver?

Selenium Interview Questions For Experienced

  • What is a Framework?
  • What are the different kinds of Frameworks?
  • What is a keyword-driven Framework?
  • What is the Hybrid Framework?
  • Different components of your framework?
  • Can you explain the Framework flow with a diagram?
  • How do you accommodate project-specific methods in your framework?
  • How is the failure handled in your framework?
  • What kind of reports are generated by your framework?
  • Explain your framework
  • Where do you implement oops concept in your framework
  • What if we use both explicit and implicit wait
  • Types of framework and differences b/w them
  • What is page object design pattern
  • Page Object Model for Selenium using TestNG,
  • BDD framework using Gherkins,
  • Cypress Page Object Model with JS,
  • API testing Automation framework using KARATE
  • GraphQL testing framework
  • String is Palindrome or not
  • How to find all links / broken in webpage
  • Given one website and do some actions using Selenium (create a user, delete an item, etc)
  • HashMap uses
  • OOPS in POM
  • Framework explanation
  • HTTP methods
  • DOM means
  • Collections used in Selenium
  • Window Handles
  • Alerts
  • Authentication popup
  • Alerts using Auto IT
  • Keyboard actions
  • iframes
  • Exceptions in Selenium while coding
  • Access modifiers in Java
  • static block, static variable, and static method
  • Explain the Page Object Model (POM) in Selenium WebDriver and its advantages in test automation.
  • How do you handle dynamic elements or waits in Selenium WebDriver scripts?
  • What are the different locators used in Selenium WebDriver? When do you prefer one over the other?
  • Explain TestNG and its role in Selenium test automation. How do you manage test suites and dependencies?
  • How do you handle browser windows and pop-ups in Selenium WebDriver tests?
  • Describe how you handle data-driven testing in Selenium using TestNG Data Providers or other approaches.
  • How do you perform parallel test execution in Selenium WebDriver to expedite test runs?
  • Discuss the difference between findElement() and findElements() methods in Selenium WebDriver.
  • What is Test Automation Framework, and how have you implemented or contributed to it in your projects?
  • How do you handle handling test failures in Selenium WebDriver? Explain TestNG listeners or other techniques you’ve used

Selenium Interview Questions For 3 Years Experience

  • Which is the default port on which selenium RC runs?
  • What are the prerequisites to run a Selenium web driver?
  • What is the difference between selenium 1.0 and web driver?
  • What are the advantages of the selenium web driver?
  • How to handle multiple windows in selenium webdriver?
  • Which locators are used to recognize the objects in the selenium webdriver?
  • What is webdriver-backed selenium?
  • When to use web driver-backed selenium?
  • How to invoke an application in webdriver?
  • Where to download selenium webdriver?
  • Explain the technical problems that you had with the Selenium tool.
  • What is Selenium Grid?
  • How many browsers are supported by Selenium IDE?
  • Can Selenium test an application on the iPhone’s Mobile Safari browser?
  • Can Selenium test an application on an Android browser?
  • How many programming languages can you use in the Selenium Web driver?
  • Have you read any good books on selenium?
  • Use of following-sibling?
  • What is the Page Object design pattern?
  • What is StaleElementException? When does it occur?
  • How to get the number of frames on a page?
  • How to verify that an element is not present on a page?
  • How do you simulate the scroll-down action?
  • What is the Robot class?
  • How do you verify that the given list of numbers on a web page is sorted in ascending order?
  • How to verify the presence of the success message on a page?
  • Which is the package which is to be imported while working with a webdriver?
  • Who was the first person who started working on selenium?
  • Who is the person who started on a webdriver?
  • How to verify whether the background color of a paragraph is green or not?
  • How to verify that the image changes on mouse hover?
  • How to log in to Facebook using webdriver?
  • How do you check whether the pagination on the Google search page is working fine or not?
  • How to check if an element is visible on the web page?
  • How to check if a button is enabled on the page?
  • How to check if a text is highlighted on the page?
  • What is selenium’s recording language?
  • What are the capabilities of Selenium IDE?
  • What are the selenium components?
  • How do you insert a breakpoint in Selenium IDE?
  • How do you insert a comment in Selenium IDE?
  • How do you handle Ajax controls using selenium?
  • How do you handle the secured connection error in HTTPS?
  • How do you compare two strings or values that are the same?
  • How do you handle the dynamic alerts that don’t always appear?
  • How to upload a file using selenium?
  • How to navigate with browser buttons in selenium webdriver?
  • How to run the tests without a browser or with an HTML unit driver in Selenium webdriver?
  • How to check if the checkbox or radio button is selected?
  • How do I get the title of the page?
  • How do you get the width of the textbox?
  • How do you get the attribute of the web element?
  • How do you read the text from the hidden elements?
  • What is the use of Apache POI?
  • How to check whether a text is underlined or not?
  • How to verify whether the size of a div is 320px or not?
  • How to check the cursor type changes on hovering over a link?
  • How to verify that the font size of a text is 12px?
  • How to verify that an image is to the right of the text?
  • How to verify the presence of a horizontal line on a page?
  • How to change the URL on a web page using a selenium web driver?
  • How to get the CSS attribute of a web element using the web driver?
  • How to verify the presence of tooltips on a web page?
  • How to hover the mouse over an element?
  • What is the use of the getOptions() method?
  • What is the use of the deSelectAll() method?
  • Can you handle Flash using a web driver?
  • Is WebElement an interface or a class?
  • FirefoxDriver is a class or an interface. From where is it inherited?
  • Which is the super interface of the webdriver?
  • What is the difference b/w close() and quit()?
  • What is the difference between gettingWindowHandles () and gettingWindowHandle ()?
  • What is the use of contextClick()?
  • How to press Shift+Tab?
  • How do you enter :(colon using web driver)?
  • How to perform double click using webdriver?
  • How do you check whether clicking an element or a new tab will open before clicking on that element?
  • What is the use of AutoIt?
  • What is the difference between dragAndDrop() and dragAndDropBy()?
  • How to type text in a new line inside of a text area?
  • How to switch back from a frame?
  • What is the use of getPageSource()?

Selenium Interview Questions For 5 Years Experience

  • Explain the Selenium Architecture
  • Difference between Selenium-IDE & Selenium RC, WebDriver
  • Difference between
    WebDriver driver = new FirefoxDriver()
    FirefoxDriver driver = new FirefoxDriver()
  • Difference between get(), navigate().to()
  • What is API, and where is it being used
  • Difference between quit() & close()
  • How to maximize & minimize the browser
  • What is webdriver โ€œinterfaceโ€ or Class
  • What is a Super interface for WebDriver
  • What is WebElement & explain all the Mtds available in WebElement
  • How many locators are available in Webdriver, & which locator is preferred
  • How to check whether the object is available in the GUI
  • How to check the text from the UI
  • How to capture color, height, width, font โ€“ the size of the Element
  • How to get the Location of the Web element
  • How to check whether the object is selected or not?
  • How to check whether the object is enabled in the GUI
  • How to Delete All Cookies
  • Do we use any constructor in webdriver
  • How to Compare Image
  • How to get the web element height & width
  • Question on WebDriver wait statement
  • What is Synchronization
  • How to handle Synchronization wait available in Webdriver
  • Which wait statement will be used to wait until the page loads?
  • How to handle dynamic object
  • The difference between thread waits, implicitly wait, and explicitly wait.
  • What is a fluent wait?
  • Question DropDown & keyboard & mouse operation
  • How to handle drop-down
  • List out all ends available in the Select class
  • How to capture all the values from the drop-down
  • How to capture only Selected values from the drop-down
  • How to capture only non-selected values from the drop-down
  • How to how with the multi-select value from the drop-down
  • How to select all the similar values from the drop-down
  • EG, we have a multi-select drop-down, like automation testing, manual testing, SQL testing, and Java; we should have all the option that contains the โ€œtestingโ€ word
  • How to work with custom select dropdown/ autosuggest dropDown
  • How to take mouse over operation on the element
  • How to perform keyboard operation
  • How to perform โ€œcontrol+c.โ€
  • Difference between build() & perform()
  • How to perform drogAndDrop Operation
  • How to perform a right-click operation

Selenium Webdriver Interview Questions on Window Handling

  • How to work with a new Tab, new Browse-window
  • How to work with the new Tab and new Browse-window with our GetWindowHAnles() Ltd
  • How to handle Alert popup
  • How to work Calender POP-up
  • How to work with advertisement popup
  • How to work with SSL pop-up
  • How to File Download PopUP
  • How to handle File Upload Pop-up using AutoIT
  • How to Handle File Upload Pop-up using ROBOT class
  • How to Handle Browser Scroll-bar
  • How to execute javascript
  • What are the different types of assertions you use in your framework?
  • What type of error do you get when assertions get fail?
  • Explain where you use encapsulation and polymorphism in your project.
  • What are the different design patterns that you use in your automation framework?
  • What is Static in Java? Explain at least 7 points about it.
  • How do you use a simple text file and JSON file in your project?
  • What are the different components of a Header in any request?
  • Who assigned test cases to your team, you or your test leads?
  • What is test estimation? What approach did you use for test estimation?
  • How do you measure the cost of quality?
  • What are the main tasks of Test Closure Activities?
  • What is Project Risk, what are some of the common project risks

Selenium Interview Questions On Frame Handle

  • How to work with frame-Window
  • How to Work with Nested Frame
  • How to work with multiple frames
  • How many ways to work with a frame
  • How to work frame when the frame does not have the id & @name attribute

Selenium Interview Questions For Multiple Browser

  • What is IllegalState Exception
  • How to work with IE, Chrome browser
  • How to write XPath in IE & chrome browser

Selenium Interview Questions For 2 Years Experience

  • What is a framework? Explain types of framework.
  • Which framework have you used & WHY?
  • Explain the framework with components.
  • What are Explicit wait and Implicit wait?
  • What is a headless browser?
  • How to get a screenshot in Selenium? Can you write the syntax?
  • What are the different types of Locators in Selenium?
  • What is the best way to locate a web element without a unique XPath?
  • What is the StaleElementReferenceException? Have you ever encountered it, and how have you handled it?
  • Do you test cases in parallel with TestNG? If yes, how many threads, and does it cause any problems?
  • What is the most common locator you use in your project?
  • Have you ever done the profiling of a web page?
  • How frequently do you use Thread.Sleep()?
  • Suppose two elements on a web page have the same IDs; how will you handle it?
  • Can we create an object for an interface?
  • What is the difference between @BeforeTest and @BeforeMethod in TestNG?
  • How does Selenium interact with the Web browser?
  • Can you make the constructor of a class static?
  • How do you maintain your test scripts, and how frequently do you modify them?
  • How to find all broken links on a webpage?
  • Explain your Automation Framework.
  • Write a dynamic XPath to locate a table’s 2nd-row 3rd-column data.
  • Hash map vs. Hash table.
  • What is the significance of the hash table?
  • What is the return type of findElements?
  • Whatโ€™s the difference between a Maven project and a Java project?
  • Getwindowhandle vs. Getwindowhandles and the return types.
  • Comparable vs. comparator.
  • Explain the project along with how the Automation was done.
  • How to upload a file in Selenium?
  • How to upload a file without using Sendkeys?
  • How to connect to a Database using Selenium?
  • Any idea or experience with the Continuous Integration tool?
  • How to handle a drop-down in Selenium?
  • What is the advantage of selenium Webdriver
  • What is the difference between findelements and findelement
  • How do you locate elements on a web page using Selenium WebDriver?
  • What are the different types of locators supported by Selenium WebDriver?
  • How do you handle dynamic elements on a web page in Selenium?
  • What is the importance of implicit and explicit waits in Selenium WebDriver?
  • How do you handle multiple windows and frames using Selenium WebDriver?
  • Explain the concept of TestNG and how it is used with Selenium for test automation.
  • How do you perform mouse and keyboard actions using Selenium WebDriver?
  • What are the advantages and limitations of Selenium for test automation?
  • How do you handle SSL certificates and security-related issues in Selenium?
  • Can you automate testing for mobile applications using Selenium? If yes, how?
  • How do you manage test data and test configurations in Selenium tests?
  • What is the Page Object Model (POM), and why is it used in Selenium automation?
  • How do you handle exceptions and errors in Selenium WebDriver scripts?
  • How to take screenshots in Selenium?
  • Data provider in the TESTNG?
  • How do you validate whether links are valid or not on the webpage?
  • How do you manage drag-and-drop activity in selenium?
  • What is the use of the testng.xml file

Selenium Automation Testing Interview Questions

  • Is Selenium 2.0 different from Selenium 3.0? If so, how?
  • Explain XPath.
  • What are the test types supported by Selenium?
  • How many types of WebDriver APIs are available in Selenium?
  • What is an exceptional test in Selenium?
  • What is POM (Page Object Model)? What are its advantages?
  • What are the different types of annotations used in Selenium? Explain the JUnit annotation linked with Selenium.
  • What are the four elements that you have to pass in Selenium?
  • What are the data-driven frameworks and keyword-driven frameworks?
  • Difference between getwindowhandles() and getwindowhandle()?
  • Can you arrange the below testng.xml tags from parent to child?
  • How to pass parameters through the testng.xml file to a test case?
  • What is TestNG Assert? Can you list common TestNG Assertions?
  • How can we create a data-driven framework using TestNG?
  • Explain Java Main Method public static void main (String[] args)
  • Explain OOPS concepts in Java.
  • Explain the Java Collections Framework.
  • What do you know about the Hierarchy of Collections in Java?
  • Are you aware of the uses of the List Interface?
  • How will you convert a string array to an ArrayList?
  • intpasrcomvert
  • intparconvert
  • I want to add a null element to HashSet and TreeSet. Can I?
  • What do you know about LinkedHashSet?
  • Write a Java program to find the highest occurrence of characters in a given word. For example, if the word is Nayar, the output is a:2, and if the word is “aabbc,” the output is “a:2,b:2.”
  • How do you handle windows in selenium?
  • The login should be done manually from the home page to execute the scripts; how?

Java Automation Testing Interview Questions

  • What is an abstract class?
  • What is the difference between abstract and interface?
  • Purpose of constructor in Java?
  • Can abstract class have a constructor?
  • Is it possible to create an object for an abstract class?
  • What is the difference between collection and collections?
  • What is set?
  • What is the difference between Hast Set and Tree Set?
  • What is the difference between Hashmap and Linked Hashmap?
  • How do you initiate a thread?
  • Do you know thread concepts?
  • What are the Selenium suite components?
  • What are the limitations of Selenium testing?
  • What are the testing types supported by Selenium? 
  • What is the difference between Selenium 3.0 and Selenium 4.0? 
  • What is the same-origin policy, and how is it handled?
  • What is Selenese? How is it classified?
  • Mention the types of Web locators.
  • What are the types of waits supported by WebDriver?
  • Mention the types of navigation commands 
  • What is the major difference between driver.close() and driver.quit()?
  • What makes Selenium such a widely used testing tool? Give reasons.
  • How to type text in an input box using Selenium?
  • How to click on a hyperlink in Selenium?
  • How to scroll down a page using JavaScript?
  • How to assert the title of a webpage? 
  • How to mouse hover over a web element? 
  • How do you retrieve the CSS properties of an element?
  • What is POM (Page Object Model)?
  • Can Captcha be automated?
  • How does Selenium handle Windows-based pop-ups?
  • How to take screenshots in WebDriver?
  • Is there a way to type in a textbox without using sendKeys()?
  • How to select a value from a dropdown in Selenium WebDriver?
  • What does the switchTo() command do? 
  • How to upload a file in Selenium WebDriver? 
  • How to set browser window size in Selenium?
  • When do we use findElement() and findElements()?
  • What is a pause on an exception in Selenium IDE? 
  • How to login to any site if it is showing an Authentication Pop-Up for Username and Password?
  • What is the difference between single and double slash in Xpath?
  • How do you find broken links in Selenium WebDriver?
  • What is test automation or automation testing?
  • What are the advantages of automation testing?
  • Name some of the commonly used automation testing tools that are used for functional automation.
  • Name some of the commonly used automation testing tools that are used for non-functional automation.
  • List out some of the automation tools that could be integrated with Selenium to achieve continuous testing.
  • What do you mean by the assertion in Selenium?
  • Explain the difference between assert and verify commands.
  • What do you mean by XPath?
  • Explain XPath Absolute and XPath attributes.
  • What is the difference between “/” and “//” in XPath?
  • What are the different types of annotations used in Selenium?
  • What are the WebDriver-supported Mobile Testing Drivers?
  • What is the difference between type keys and type commands?
  • What is the difference between the “type” and “typeAndWait” commands?
  • What is the main disadvantage of implicit wait?
  • How can we launch different browsers in Selenium WebDriver?
  • Write a code snippet to launch the Firefox browser in WebDriver.
  • Write a code snippet to launch the Chrome browser in WebDriver.
  • Write a code snippet to launch the Internet Explorer browser in WebDriver.
  • How do you perform drag-and-drop operations in WebDriver?
  • What are the different methods to refresh a web page in WebDriver?
  • How to invoke an application in WebDriver?
  • What are the benefits of automation testing?
  • Is there an HtmlUnitDriver for .NET?
  • How can you redirect browsing from a browser through some proxy

Selenium Interview Questions I faced in a recent interview.

  • How to Exclude test cases that don’t want to run.
  • How to Iterate Map.
  • String str=” this is your order number 123456″
  • How do you fetch the only number from this string?
  • How to handle steal element exception.what you will write in the catch block
  • How to find 2 maximum numbers from the array.
  • How do you remove all space from the array?
  • Difference between ArrayList and Map
  • If sendkeys is not working, what you will do with any other alternative?
  • How to remove duplicate from the string.
<div>
<button id="sdf"> 
<div id="vxvxcv"> 
</div>
  • Write XPath to find the first div.
  • Write code that gets all the links and click on every link.
  • 5 Exception in selenium.
  • Rest Assured code.
  • The SQL query to find the top 10 rows from the table.
  • Advantage of cucumber framework
  • Other BBD tools apart from the cucumber.
  • How to achieve parametrization in cucumber.
  • How to get all links from a webpage
  • How to get all broken links from the webpage
  • How to find hidden elements from UI
  • Use of robot class.
  • How to convert date in another formate .20192207- 2019-22-07
  • WebDriver Listeners and TestNG Listeners
  • Taking data from an Excel sheet is slow, so what is the alternative?
  • Cucumber dependency is language-specific or not?
  • Protector.?
  • TestNG Annotation order.

Automation Testing Interview Questions For Freshers

  • Write code for the Action class
  • Write code for positive and negative scenarios for Alerts
  • Write code for handling multiple windows
  • Find an odd number
  • Disadvantages of Selenium
  • Difference between get() and navigate().to()
  • Write code to click on the Checkbox which is inside the Dynamic Table
  • Write code for taking Screenshot
  • Explains Maps in Java
  • Explain framework (Questions based on your framework explanation)
  • What is Pom.xml
  • Which is the correct Xpath for this code (Lot of questions on Xpath)
  • Xpath methods Ex: Starts-with & Contains
  • The syntax for a CSS selector
  • How to identify dynamic images
  • From a given string, separate characters, integers, and special characters and stored in a separate variable and printed them
  • Remove duplicates from ArrayList
  • Print all the frame names
  • How to read from XML or CSV file and store in hashmap
  • Get the value of a cell in the Dynamic table
  • What is the Burndown chart (Agile)
  • Print these characters from a given string and change them to uppercase
  • Explain Access specifiers
  • Difference between Priority and Severity
  • Examples of High Priority and Low Severity and vice versa
  • Difference between Test Strategy and Test Scenario
  • What Software Metrics you have used in your project
  • How to handle Dynamic Elements, since the webpage is designed in Angular JS
  • Implicit and Explicit Waits
  • Write code for Cross Browser Testing
  • Explain Method Overloading and Method Overriding with Example
  • What is a Static Keyword
  • Dependencies in Pom.xml
  • Write code for fetching data from Excel
  • Select this value in the dropdown, hover over this element, and click
  • Assert and Verify
  • Check if a given string is Palindrome or not
  • Remove duplicate characters from a string and print
  • Which Code Repository you are using (Ex: GitHub)
  • What is Software testing?
  • What are the different types of testing?
  • What are the principles of software testing?
  • What is regression testing in software testing?
  • What is exploratory testing?
  • What is end-to-end testing?
  • What is unit testing?
  • What is an API?
  • What is a test environment?
  • Explain how a test coverage tool works.
  • Can you describe the different types of test coverage techniques?
  • Explain black-box testing, white-box testing, and grey-box testing.
  • Is Automation testing in agile methodology useful?
  • Explain test scenarios, test scripts, and test cases in software testing.
  • What is a bug in software testing?
  • State the difference between bugs and errors
  • What is a Test Plan? What does it include?
  • What is a Test Report? What does it include?
  • What do you mean by Test Deliverables?
  • What are the different categories of debugging?
  • Write some common mistakes that lead to major issues.
  • What is a user story?
  • List some of the popular software testing tools/frameworks, providing a brief description of each.
  • What is A/B testing?
  • What are defects in software testing?
  • What is a spice in software testing?
  • What do you mean by latent defect and masked defect?
  • Can you explain sanity testing in software testing?
  • What is the purpose of TestNG?
  • Is it possible to skip a method or a code block in TestNG?
  • What is the best way to set priority for test cases in TestNG?
  • What is an Object Repository?
  • What are the valuable steps to resolve issues while testing?
  • What qualities a software tester should have?
  • Explain boundary value analysis in software testing.
  • Explain the role of testing in software development.
  • How much testing is sufficient? Or is it possible to do exhaustive testing of the software?
  • Why developers shouldnโ€™t test the software they wrote?
  • What is SDLC in software testing?
  • What is the software testing life cycle?
  • What is functional testing?
  • What is non-functional testing?
  • What is a bug report?
  • What are some important testing metrics?
  • What is test-driven development?
  • What is Selenium? What are its benefits?
  • What are the various components of Selenium?
  • What is cross-browser testing?
  • What are the different HTTP status codes that a server can return?
  • What is automated testing?
  • What is the most effective way to map automation testing success?
  • What are the different types of severity you can assign to a bug?
  • Which test cases are written first: white boxes or black boxes?
  • What is alpha testing?
  • What is beta testing?
  • What is meant by browser automation?
  • What do you mean by Test Matrix and Traceability Matrix?
  • What is the V model in software testing?
  • State the difference between verification and validation in software testing.
  • What is static software testing?
  • What is dynamic software testing?
  • What do you mean by confirmation testing in software testing?
  • What is the defect life cycle?
  • What is defect cascading in Software testing?
  • A defect that could have been removed during the initial stage is later removed. What effect does this have on the cost?
  • What is meant by the workbench concept?
  • When there is neither a frame ID nor a frame name, what technique should be considered in the script?
  • How can Selenium WebDriver be used to detect broken links

Automation Testing Interview Questions For 5 Years Experience

  • What is the use of the โ€˜superโ€™ keyword inside a constructor?
  • Explain the concept of proper inheritance.
  • What are abstract classes and anonymous classes?
  • When should a function throw an exception?
  • How can you insert values in multiple rows using one Insert statement?
  • Explain access specifiers.
  • What are TCP/IP protocols?
  • What are near, far, and huge pointers?
  • Explain the waterfall model.
  • What is the difference between a Linked list and a Queue?
  • What are bitfields? What is the use of bit fields in a Structure declaration?
  • Write an algorithm for quick sorting.
  • What is a cursor?
  • What is the difference between rowid and rownum in SQL?
  • What are the different synchronization mechanisms?
  • Can a static member function access the member variable of an object?
  • What is the difference between the member variable’s initialization and assignment in a constructor?
  • What is the use of the ‘classpath’ environment variable?
  • What is the use of the StringTokenizer class?
  • Today is Monday. After 61 days, it will be?
  • Difference between operator overloading and function overloading
  • Can you instantiate an abstract class and what an inner class is?
  • When do you call the copy constructor?
  • How can you swap values between two rows in a table using a single- SQL statement?
  • What is the type of this pointer?
  • What do you mean by data hiding?
  • What is Function Overloading?
  • What is SDLC?
  • Explain the key functions of data binding.
  • We know that we can maximize or minimize the browser window. However, we need to test the UAT’s responsiveness in different browser screen sizes. Can this be done in Selenium?
  • How to send ALT/SHIFT/CONTROL keys at once in Selenium WebDriver?
  • How can you upload a file using Selenium WebDriver?
  • What technique should you use throughout the script if there is neither a frame ID nor a frame name?
  • You have written an automation code with both implicit and explicit wait commands. However, the elementNotVisible exception is still thrown. How do you fix this issue without extending the wait times to implicit or explicit waits?
  • How can you use regular expressions in Selenium?
  • You need to retrieve the message in an alert box without using the getText() method. How will you handle this situation?
  • Consider a website that requires a username, password, and captcha for the user to log in. Your colleague suggests that this test execution can be redirected to the manual testing team. Do you agree with them? If yes, why?
  • Can you explain how you can handle colors in a web driver?
  • You are given a set of highly confidential automated scripts that must be run on the clientโ€™s remote server only. If you are asked to modify the scripts based on privacy needs, what will you do?
  • A fresher in your team encounters a โ€˜StaleElementโ€™ exception while executing an automated test suite. How will you help them solve this issue?
  • How is network data capturing done in Selenium?
  • You have been asked to perform automation testing on a website that loads slowly. You are able to execute the scenario manually without any impediments other than the speed issue. But during automation, a NoSuchElementFound exception is thrown.
  • Your test lead suggests making a change in the navigation commands. How will you handle this situation?
  • Which command takes you forward by one page in the browser history?
  • How will you enable a disabled textbox?
  • Your suite execution has failed, and only a few test cases have passed. How will you optimize your upcoming test runs in Selenium?
  • How can you debug the tests in the Selenium IDE?
  • How to verify the specific position of a web element?
  • How is the desired capability useful in terms of Selenium?
  • John is not sure if the warning text label is displayed on the web page of a blog. How will you help him using Selenium?
  • Your team needs to check if a warning message is displayed when the user’s password is moderately secure.
  • There are different datasets where some passwords entered by the user are secure, so the warning message does not appear on the page. This should not halt the execution of the next steps in the test script. Can we use Assert commands to test this scenario?
  • Which type command should you use if there is a reload event once your typing is completed?
  • The Selenium script runs in Chrome but not in IE. What can be done?
  • How do you write an Xpath locator to identify paragraph elements that are the immediate child of a div element or the descendent of a div element?
  • How do you take a screenshot with Selenium Webdriver?

Selenium Java Interview Questions

What is Automation Testing?
Ans: Automation testing, or Test Automation, is a process of automating the manual process of testing the application/system under test. It 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.

What are the benefits of Automation Testing?
Ans: Benefits of Automation testing are:

  • Supports execution of repeated test cases
  • Aids in testing a large test matrix
  • Enables parallel execution
  • Encourages unattended execution
  • Improves accuracy, thereby reducing human-generated errors
  • Saves time and money

Why should Selenium be selected as a test tool?
Ans: Selenium is a free and open-source has a large user base and helps communities have cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari, etc.), great platform compatibility (Windows, Mac OS, Linux, etc.), supports multiple programming languages (Java, C#, Ruby, Python, Pearl, etc.) has fresh and regular repository developments supports distributed testing

What is Selenium? What are the different Selenium components?
Ans: 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 among testing professionals. Selenium is not just a single tool or a utility but 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 and execute test scripts within a wide range of browsers.
  • Selenium WebDriverโ€”WebDriver is a different tool altogether that has various advantages over Selenium RC. It 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.

What are the testing types that can be supported by Selenium?
Ans: Selenium supports the following types of testing:
Functional Testing
Regression Testing

What are the limitations of Selenium?
Ans: The following are the limitations of Selenium:

  • Selenium supports the testing of only web-based applications
  • Mobile applications cannot be tested using Selenium
  • Captcha and Barcode readers cannot be tested using Selenium
  • Reports can only be generated using third-party tools like TestNG or Junit.
  • Selenium is a free tool. Thus, there is no ready vendor support through which the user can find numerous helping communities.
  • A user is expected to possess prior programming language knowledge.

When should I use Selenium IDE?
Ans: Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintance with any programming language. Selenium IDE is an ideal tool for a naรฏve user.

What is Selenese?
Ans: Selenese is the language that is used to write test scripts in Selenium IDE.

What are the different types of locators in Selenium?
Ans: A locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely, we have different types of locators in Selenium:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM

What is the difference between Assert and verify commands?
Ans:

  • Assert The 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. If the condition is true, the program control will execute the next test step, but if the condition is false, the execution will stop, and no further test will be executed.
  • Verify: The 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.

What is an XPath?
Ans: 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 similar to HTML tags. Since they are both markup languages and fall under the same umbrella, XPath can be used to locate HTML elements.

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

What is the difference between โ€œ/โ€ and โ€œ//โ€ in XPath?
Ans:

  • Single Slash โ€œ/โ€ โ€“ A single slash is used to create an XPath with an 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 an XPath with a relative path, i.e., the XPath would be created to start selection from anywhere within the document.

What is the Same-origin policy, and how can it be handled?
Ans: The problem of the same-origin policy disallows access to the DOM of a document from an origin other than the origin from which we are trying to access the document.
Origin is a sequential combination of scheme, host, and port of the URL. For example, for a URL HTTP:// http://www.softwaretestingo.com/selenium/, the origin is a combination of HTTP, softwaretestingo.com, 80 correspondingly.
Thus, the Selenium Core (JavaScript Program) cannot access elements from an origin other than where it was launched. For Example, if I launched the JavaScript Program from โ€œhttp://www.softwaretestingo.com,โ€ then I would be able to access pages within the same domain, such as โ€œhttp://www.softwaretestingblog.in/seleniumโ€ or โ€œhttp://www.softwaretestingo.com/manual/.โ€ The other domains, like google.com and seleniumhq.org, would no longer be accessible.
So, To handle the same-origin policy, Selenium Remote Control was introduced.

When should I use Selenium Grid?
Ans: Selenium Grid can be used to execute the same or different test scripts on multiple platforms and browsers concurrently to achieve distributed test execution, test under different environments, and save execution time remarkably.

What do we mean by Selenium 1 and Selenium 2?
Ans: Selenium RC and WebDriver, in combination, are popularly known as Selenium 2. Selenium RC alone is also referred to as Selenium 1.

Which is the latest Selenium tool?
Ans: WebDriver

How do I launch the browser using WebDriver?
Ans: The following syntax can be used to launch Browser:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();

What are the different types of Drivers available in WebDriver?
Ans: The different drivers available in WebDriver are:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

What are the different types of waits available in WebDriver?
Ans: There are two types of waits available in WebDriver:
Implicit Wait
Explicit Wait

  • Implicit Wait: Implicit waits provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, the subsequent test step would only execute when 30 seconds have elapsed after executing the previous test step/command.
  • Explicit Wait: Explicit waits halt the execution until a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied to a particular instance only.

How to type in a textbox using Selenium?
Ans: The user can use sendKeys(โ€œString to be enteredโ€) to enter the string in the textbox.
Syntax:
WebElement username = drv.findElement(By.id(โ€œEmailโ€));
// entering username
username.sendKeys(โ€œsthโ€);

How can you find if an element is displayed on the screen?
Ans: WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels, etc.
isDisplayed()
isSelected()
isEnabled()
Syntax:

isDisplayed():

boolean buttonPresence = driver.findElement(By.id(โ€œgbqfbaโ€)).isDisplayed();

isSelected():

boolean buttonSelected = driver.findElement(By.id(โ€œgbqfbaโ€)).isSelected();

isEnabled():

boolean searchIconEnabled = driver.findElement(By.id(โ€œgbqfbโ€)).isEnabled();

How can we get a text from a web element?
Ans: The get command retrieves the inner text of the specified web element. It doesnโ€™t require any parameters and returns a string value. It is also one of the extensively used commands for verifying messages, labels, errors, etc., displayed on web pages.
Syntax:
String Text = driver.findElement(By.id(โ€œTextโ€)).getText();

How to select a value in a dropdown?
Ans: Value in the dropdown can be selected using WebDriverโ€™s Select class.
Syntax:

selectByValue:

Select selectByValue = new Select(driver.findElement(By.id(โ€œSelectID_Oneโ€))); selectByValue.selectByValue(โ€œgreenvalueโ€); 

selectByVisibleText:

Select selectByVisibleText = new Select (driver.findElement(By.id(โ€œSelectID_Twoโ€))); selectByVisibleText.selectByVisibleText(โ€œLimeโ€);

selectByIndex:

Select selectByIndex = new Select(driver.findElement(By.id(โ€œSelectID_Threeโ€))); selectByIndex.selectByIndex(2);

What are the different types of navigation commands?
Ans: The following are the navigation commands:

  • navigate().back() โ€“ The above command requires no parameters and takes back the user to the previous webpage in the web browserโ€™s history.
    Sample code:
    driver.navigate().back();
  • navigate().forward() โ€“ This command lets the user navigate to the next web page with reference to the browserโ€™s history.
    Sample code:
    driver.navigate().forward();
  • navigate().refresh() โ€“ This command lets the user refresh the current web page there by reloading all the web elements.
    Sample code:
    driver.navigate().refresh();
  • navigate().to() โ€“ This command lets the user launch a new web browser window and navigate to the specified URL.
    Sample code:
    driver.navigate().to(โ€œhttps://google.comโ€);

How to click on a hyperlink using linkText?
Ans: driver.findElement(By.linkText(โ€œGoogleโ€)).click();
The command finds the element using link text. The user then clicks on that element and is redirected to the corresponding page.
The above-mentioned link can also be accessed by using the following command.
driver.findElement (By.partialLinkText(โ€œGooโ€)).click();
The above command finds the element based on the substring of the link provided in the parenthesis, and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

How to handle frame in WebDriver?
Ans: An inline frame acronym, as an iframe, is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting.

  • Select iframe by id
    driver.switchTo().frame(โ€œID of the frameโ€œ);
  • Locating iframe using tagName
    driver.switchTo().frame (driver.findElements (By.tagName(โ€œiframeโ€).get(0));
  • Locating iframe using index
    frame(index)
    driver.switchTo().frame(0);
  • frame(Name of Frame)
    driver.switchTo().frame(โ€œname of the frameโ€);
    frame(WebElement element)
    Select Parent Window
    driver.switchTo().defaultContent();

When do we use findElement() and findElements()?
Ans:

findElement(): findElement() is used to find the first element in the current web page matching the specified locator value. Only the first matching element will be fetched.
Syntax:

WebElement element = driver.findElements(By.xpath(โ€œ//div[@id=โ€™exampleโ€™]//ul//liโ€));

findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take note that all the matching elements will be fetched and stored in the WebElements list.
Syntax:

List <WebElement> elementList = driver.findElements(By.xpath(โ€œ//div[@id=โ€™exampleโ€™]//ul//liโ€));

How do you find more than one web element on the list?
Ans: At times, we may come across elements of the same type, such as multiple hyperlinks, images, etc., arranged in an ordered or unordered list. Thus, it makes absolute sense to deal with such elements by a single piece of code, and this can be done using the WebElement List.
Sample Code

// Storing the list
List <WebElement> elementList = driver.findElements(By.xpath("//div[@id='example']//ul//li"));
// Fetching the size of the list
int listSize = elementList.size();
for (int i=0; i<listSize; i++)
{
   // Clicking on each service provider link
   serviceProviderLinks.get(i).click();
   // Navigating back to the previous page that stores link to service providers
   driver.navigate().back();
}

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

  • Close (): WebDriverโ€™s close() method closes the web browser window that the user is currently working on, or, more accurately, the window that is being currently accessed by the WebDriver. The command neither requires any parameters nor returns any value.
  • Quit (): Unlike the close() method, the quit() method closes down all the windows that the program has opened. Unlike the close() method, the command neither requires any parameters nor returns any value.

Can Selenium handle Windows-based pop-ups?
Ans: Selenium is an automation testing tool that supports only web application testing. Therefore, windows pop-ups cannot be handled using Selenium.

How can we handle web-based pop-ups?
Ans: WebDriver offers users a very efficient way to handle these pop-ups using the Alert interface. We would use four methods along with the Alert interface.

  • Void dismiss() โ€“ The accept() method clicks on the โ€œCancelโ€ button as soon as the pop-up window appears.
  • Void accept() โ€“ The accept() method clicks on the โ€œOkโ€ button as soon as the pop-up window appears.
  • String getText() โ€“ The getText() method returns

What is Selenium, and what are its components?
Answer: Selenium is an open-source framework for automating web browser interactions. It consists of various components:

  • WebDriver: The core component that interacts with the browser through drivers like ChromeDriver (Chrome), FirefoxDriver (Firefox), etc.
  • Language Bindings: APIs for different programming languages, such as Java, Python, JavaScript, etc., to interact with WebDriver.
  • Selenium IDE: A record-and-playback tool for creating basic test scripts.
  • Selenium Grid: Distributed test execution across multiple machines for parallel testing.

What are the advantages of using Selenium?
Answer:

  • Reduced testing time and effort: Automates repetitive tasks, leading to faster testing cycles.
  • Improved test coverage: Enables testing complex scenarios and edge cases manually.
  • Increased software quality: Catches more bugs and improves overall software reliability.
  • Cross-browser compatibility: Supports testing across different browsers and operating systems.
  • Open-source and free to use: Reduces costs compared to proprietary automation tools.

What are the different types of locators used for identifying web elements?
Answer: Locators specify how to find specific elements on a web page. Some common types include:

  • ID: Unique identifier of an element (e.g., #login_button).
  • Name: Attribute assigned to the element (e.g., username).
  • Class name: Class assigned to the element (e.g., error_message).
  • XPath: Powerful path-based expression to locate elements based on their structure.
  • CSS selector: Similar to CSS selectors used for styling, targeting elements based on their attributes and relationships.
  • TagName
  • Link Text
  • Partial Link Text

Describe different types of web testing supported by Selenium.
Answer:

  • Functional Testing: Verifies core functionality of the web application.
  • Regression Testing: Ensures existing functionality remains intact after changes.
  • Smoke Testing: Basic tests to confirm core features work before deeper testing.
  • Ul Testing: Validates user interface elements and their behavior.
  • Cross-browser Testing: Tests the application across different browsers and platforms.

What are some common challenges faced in Selenium automation, and how do you address them?
Answer: Common challenges include:

  • Element not found: Use reliable locators, check for stale element references, and implement wait mechanisms.
  • Synchronization issues: Use explicit waits for specific conditions like page load or element visibility.
  • Popups and alerts: Implement pop-up handling strategies like dismissing or entering data.
  • Cross-browser compatibility issues: Leverage WebDriver capabilities for different browsers and adjust locators if needed.

Can you explain the concept of Page Object Model (POM) in Selenium?
Answer: POM is a design pattern for organizing test code by grouping elements and actions associated with specific web pages. This improves code modularity, reusability, and maintainability. It involves creating separate classes for each page, encapsulating elements and actions within that page.

How do you handle data in your Selenium scripts?
Answer: You can use various approaches:

  • Hardcoded data: Embed data directly into the script, which is suitable for simple cases.
  • Data files: Store data in external files like CSV or Excel, which are easily read and updated.
  • Database connections: Use database connections to retrieve test data dynamically.

Choose the approach based on your data complexity and test needs.

What are some best practices for writing maintainable Selenium scripts?
Answer:

  • Use descriptive variable names and comments.
  • Break down complex actions into smaller functions.
  • Follow consistent coding conventions.
  • Log actions and errors for debugging purposes.
  • Use configuration files for environment settings.

Can you explain how Selenium interacts with the web browser through drivers?
Answer: Selenium drivers act as bridges between your programming language and the browser. They translate your commands into browser-specific actions, like clicking buttons or entering text. Different browsers require specific drivers, like ChromeDriver for Chrome and FirefoxDriver for Firefox. These drivers communicate with the browser’s internal automation interfaces to perform the desired actions.

How can I handle dynamic web elements that change their IDs or other properties?
Answer: Relying solely on specific locators like IDs can be fragile. Consider using more robust approaches like:

  • XPath with relative paths based on element relationships.
  • CSS selectors based on element attributes and class names.
  • Additionally, wait mechanisms like WebDriverWait can ensure elements are present and stable before interacting with them.
  • Page Object Model (POM) to encapsulate element identification logic in separate classes.

What are some common challenges faced when using Selenium?
Answer:

  • Element identification issues: Locating elements dynamically or those with changing attributes can be tricky.
  • Synchronization: Ensuring elements are ready before interacting with them can be challenging.
  • Cross-browser compatibility issues: Some features might not work consistently across all browsers.
  • Debugging test failures: Identifying the root cause of failed tests can be time-consuming.

Explain the difference between findElement and findElements methods in Selenium.
Answer:

  • findElement returns the first matching element for a given locator. If no element is found, it throws a NoSuchElementException.
  • findElements returns a list of all matching elements for a given locator. If no element is found, it returns an empty list.

How do you handle synchronization issues in Selenium?
Answer:

  • Explicit waits (WebDriverWait) with Expected Conditions like element ToBeClickable and visibilityOfElementLocated.
  • Implicit waits are set globally to wait for a certain amount of time before throwing an exception.
  • Fluent waits are used for polling and checking element availability

Describe your experience with handling popups and alerts in Selenium.
Answer: Discuss handling strategies like switching to popup frames, dismissing buttons, sending text to input fields, and dealing with different types of alerts.
Mention preferred methods and libraries you’ve used for popup/alert handling.

Have you experienced using different headless browsers for automation?
Discuss the advantages of headless browsers like Chrome Headless and Firefox Headless for faster execution and resource efficiency. Mention how you’ve integrated headless browsers into your Selenium testing workflow.

Why do we use WebDriver driver instead of ChromeDriver driver?
We generally do it this way because we usually want to run our tests on multiple browsers. If we declare the driver as a specific driver type, we are then anchored to only that driver. This is not a problem if you only ever need to test it on Chrome. But what if you later want your tests to also work with IE, Opera, Firefox, etc.?

These are extended classes of the WebDriver interface.

If your main tests and other classes define the commonly shared driver as simply WebDriver instead of specifically being tied to ChromeDriver, then the same tests can be run without change to the test code itself simply by initializing the shared driver object with a different driver extended class.

What is the problem with Thread.Sleep() in code?
Ans:

  • It is a Static wait: If given a wait of 5000 Milliseconds(5 seconds) and an element takes 1-2 seconds to load, the script will still wait for another 3 seconds, which is bad as it unnecessarily increases the execution time. So thread sleep() increases the execution time in cases where elements are loaded in no time.
  • When using Thread.sleep(), we have to mention the wait time in advance; there is no guarantee that the element will be displayed during that specific wait time. There may be cases when it takes more than 5 seconds to load, and again, the script would fail.
  • You need to write a sleep() method whenever we need to make the webdriver wait. So, if you want to wait for two web elements, you need to write Thread.sleep() twice just before you locate web elements.
  • It is not good programming practice. Instead, you can use implicit or explicit waits.

What expected conditions can be used in Explicit waits?
Ans: Some of the commonly used expected conditions of an element that can be used with explicit waits are:

  • elementToรŸeClickable(WebElement element or By locator)
  • stalenessOf(WebElement element)
  • visibilityOf(WebElement element)
  • visibilityOfElementLocated(By locator)
  • invisibilityOfElementLocated(By locator)
  • attributeContains(WebElement element, String attribute, String value)
  • alertisPresent()
  • titleContains(String title)
  • titlels(String title)
  • textToBePresentinElementLocated(By, String)

What will you do if there are failures in your suite execution, and what is your approach?
Ans: While executing the automation scripts, test cases may fail for several reasons. To optimize our next runs, we need to re-run only failed test cases.


How do you execute failed Test cases? What is the best approach?
Ans: In the TestNg class, we can easily re-run the test cases using two methods as explained below:
Method 1: By using the testng-failed.xml file in the test-output folder.
Method 2: By implementing TestNG IRetryAnalyzer.


Why do we use headless drivers? How can you visually investigate test failure when using headless drivers?
Ans: Headless drivers are typically used in continuous integration (CI) setups. Headless drivers, such as PhantomJS, provide all standard web browser functionalities but run in the command line. These drivers are based on command-line tools and don’t produce screen output, making them ideal for completely automated setups.

To be able to investigate test failures visually, the developer needs to implement mechanisms to capture screenshots; otherwise, rely on command line output.


What is the super interface of WebDriver?
Ans: SearchContext.
Explain the line of code Webdriver driver = newFirefoxDriver);?
Ans: ‘WebDriver’ is an interface, and we are creating an object reference of type WebDriver, instantiating an object of the FirefoxDriver class.

What are the end methods you use to verify whether the end result is achieved by our Selenium automation scripts?
Ans: We can use different assertion methods available in different test frameworks like TestNG or Junit.

How do you clear the cookies of a browser using Selenium before starting the execution?
Ans: driver.manage().deleteAllCookies();

How do you implement collections in your framework?
Ans: Collections can be used in a framework to store a large number of objects. For example, the findElements() method returns a list of all matching elements.

Give a scenario where inheritance is used in your framework.
We create a Base Class in the Framework to initialize the WebDriver interface, WebDriver waits, Property files, Excels, etc., in the Base Class. We extend the Base Class to other classes such as Tests and Utility Class.

Give a scenario where an interface is used in your framework.
WebDriver is an interface, and when we create an instance of the driver object, we use its different methods.

Write a code using JavascriptExecutor to scroll the web page.
Ans: //This will scroll the web page till the end.
is.executeScript(“window.scrollTo(0, document.body.scrol|Height)*):|

What is the use of property files in Selenium?
Ans: Property files can be used to store the different web elements of an application or to store all the different application framework configurations.

How do you handle selecting multiple browsers in Selenium?
Ans: We can select different browsers in Selenium using the TestNG framework.

What do you use to report on your Selenium Project?
Ans: We can use the default TestNG or Cucumber report, as well as different reporting libraries, such as Extent reports.


How to handle Selenium WebDriver Exceptions?
We can handle selenium exceptions by using Java’s try-catch block methods.
try
{
driver.findElement(by.id(“button”)).click():
}
catch(NoSuchElementException e)
{
System.out.printin(“Element not present ):
}

There are four browser windows open and you don’t have any idea where the required element is present. What will be your approach to finding that element?
Ans:
use the getWindowHandles() method to get the Window handles of all browser windows
use the switchTo() method to switch to each browser window using the handle id
Find the element in each browser window and close the window if not present.

How do you handle an alert pop-up in Selenium?
We can use the following methods to handle an alert in Selenium:
dismiss(): driver.switchTo().alert).dismiss():
accept(): driver.switchTo().alert).accept():

How do you retrieve the text displayed on an Alert?
String text = driver.switchTo().alert().get Text);

How do you type text into the text box on an Alert?
driver.switchTo().alert().sendKeys(“Text”);|

Is Alert in Selenium an Interface or Class?
Alert is an interface in Selenium.

How do you handle frames in Selenium?
We can switch to frames by following methods:
By Index: driver.switchTo().frame(0);
By Name or Id: driver.switchTo() frame(“id of the element”);
By Web Element: driver.switchTo().frame(WebElement);

Give an example of the method overloading concept that you have used in Selenium.
Implicit Wait in Selenium uses method overloading, as we can provide different Timestamps or time units, such as seconds, minutes, etc.

How do you select a value from a drop-down field, and what are the different methods available?
We can select values from the drop-down using the Select class method. The following are the methods:
selectByVisibleText
selectByValue
selectBylndex

When your XPath is matching more than one element, how do you handle it to locate the required element?
We can use the index of the element to locate it, or we can use different Xpath axes methods to locate the element like Following, Ancestor, Child, Preceding or Following-sibling

How do you capture screenshots in Selenium, and what is the best place to get the screenshot code?
//Convert web driver object to TakeScreenshot
TakesScreenshot scrShot =(TakesScreenshot)webdriver); |
//Call the getScreenshotAs method to create an image file
File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
//Move image file to new destination
File DestFile=new File(fileWithPath);
//Copy file at destination
FileUtils.copyFile(SrcFile, DestFile);


How do you refactor an existing automation framework?
Ans:

  • Assess the current framework’s weaknesses and maintenance challenges
  • Identify redundant or outdated code and refactor it to improve readability
  • Prioritise modularisation and design patterns for a more scalable framework
  • Implement version control and code review practices to ensure code quality
  • Introduce continuous integration for automated tests to detect integration issues

During test execution, you encounter a scenario where a test consistently fails due to intermittent issues, making it a “flaky test.” How would you troubleshoot and address this issue to ensure test stability?
Ans:

  • Analyse test logs and identify patterns in failures
  • Review the environment setup and test data to identify inconsistencies
  • Introduce explicit waits or enhance synchronisation to handle timing issues
  • Isolate the test case to identify if it’s due to application issues or test script problems
  • Collaborate with developers to address any underlying application issues causing flakiness.

Note – You can also provide answers specific to automation libraries used in the organisation.

A critical bug was discovered in the production environment. How would you prioritise creating automated tests to cover this specific scenario to prevent similar issues?
Ans:

  • Analyse the critical bug and identify test scenarios to replicate the issue
  • Prioritise automated test creation to cover affected functionality
  • Perform root cause analysis to identify similar areas prone to issues
  • Integrate automated tests into the regression suite for continuous coverage
  • Ensure collaboration between development and testing to prevent future occurrences

How would you approach automating cross-browser testing to cover various user scenarios?
Ans:

  • Utilise cross-browser testing tools like Selenium Grid, BrowserStack etc. for multi-browser testing
  • Develop test scripts that validate Ul elements and functionalities across targeted browsers
  • Leverage parameterisation to run test suites across multiple browsers in parallel for efficient validation
  • Will also make sure there are no browser-specific dependencies in the tests

When and where is FindElements better than FindElement?
Ans:

findElement: A command to uniquely identify a web element within the web page.
Throws NoSuchElementException if the element is not found
WebElement elementName = driver.findElement(By.LocatorStrategy(“LocatorValue”));
findElements: A command to identify a list of web elements within the web page. Returns an empty list if no matching element is found
List elementName = driver.findElements(By.LocatorStrategy(“LocatorValue”));

How do you handle shadow DOM elements in Selenium?
Ans: Shadow DOM is a functionality that allows the web browser to render DOM elements without putting them into the main document DOM tree. This creates a barrier between what the developer and the browser can reach; the developer cannot access the Shadow DOM the same way they would with nested elements, while the browser can render and modify that code the same way it would with nested elements.

There are some bits of Shadow DOM terminology to be aware of:

  • Shadow host: The regular DOM node to which the Shadow DOM is attached.
  • Shadow tree: The DOM tree inside the Shadow DOM.
  • Shadow boundary: The place where the Shadow DOM ends and the regular DOM begins.
  • Shadow root: The root node of the Shadow tree.

What are the ways to handle shadow DOM elements?
Ans: When we try to find the Shadow DOM elements using Selenium locators, we get NoSuchElementException as it is not directly accessible to the DOM. Selenium WebDriver’s version 4.0.0 and above, the getShadowRoot() method was introduced and helped locate Shadow root elements. In case Shadow root is not found, it will throw NoSuchShadowRootException

What are the new Selenium 4 features?
WebDriver is developed completely by W3C Standardization
The Selenium IDE support for Chrome is available now.
Selenium Grid – The hubs and nodes are now easy to set up and handle. Once a Selenium server is started, the grid will act as both a hub and a node.
Taking screenshots at the element level. Section level and page level are possible now.
Support of Relative Locators

What is the difference between Page Object Model and Page Factory?
Page Object Model (POM):

  • POM is a Selenium design pattern; we can see it as a repository where we store all the WebElements. This has become very popular in industry these days, because it is very easy to manage, reusability of code and eliminates duplication of code.
  • The key benefit if Ul changes in the future, then we can update WebElements to Page Classes in POM or Object Repository accordingly

Page Factory:

Page Factory in Selenium WebDriver is an integrated concept or API. Here we follow again the same principle of keeping repository objects or page classes separate from test classes.
Here we use @FindBy to find elements and to initialize WebElements using the initElements process

How To Overcome StaleElementReferenceException in Selenium?
The reference to an element is now “stale”; the element will no longer appear on the page’s DOM. In simple words, when you started interacting with it, the element you located using the findElement method disappeared.

Add exception handling to your action. If the exception is stale, try to locate the element after a simple wait for 500 milliseconds. Repeat these actions until the action or max iterations have been successful.

Final Words

By reviewing common Selenium interview questions and practicing your answers, you can demonstrate your expertise and showcase your ability to perform well in a Selenium testing role. It’s important to remember that every interviewer will have unique preferences and expectations, so your responses must also be flexible and adaptable.

By mastering the art of answering Selenium interview questions, you can increase your chances of landing your dream job and jumpstarting your career in software testing. With continued practice and dedication, you can become a skilled and valuable Selenium tester, contributing to the success of your organization and ensuring that web applications function smoothly and efficiently.

If you have any suggestions, feedback, or questions about Selenium Interview Questions, please feel free to ask in the comment section below. We value your opinion and would love to hear from you. Our team of experts is here to provide you with the best possible guidance and assistance.

Your feedback will help us improve and update our content to provide the most relevant and up-to-date information on Selenium interview questions. So, don’t hesitate to leave your questions or comments below, and we will get back to you as soon as possible.

Avatar for Softwaretestingo Editorial Board

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

2 thoughts on “Selenium Interview Questions”

  1. These all are very helpful to us….thanks a lot….can you do interview questions on selenium python please I m on that domain…can you please do that article on selenium python….real time interview questions

    Reply
    • Thanks Archana, for such kind words and selenium python interview questions also in our list will try to update those as well in our platform

      Reply

Leave a Comment