Java Selenium Interview Questions for Freshers
General Java Questions
- What is Java? Explain the key features of Java.
- What are OOP principles? Describe Inheritance, Polymorphism, Abstraction, and
Encapsulation with examples.
- What is the difference between JDK, JRE, and JVM?
- What are access modifiers in Java? Describe public, private, protected, and default access
modifiers.
- Explain the concept of constructors in Java.
- What are exceptions in Java? Differentiate between checked and unchecked exceptions.
- What is the difference between an ArrayList and an array in Java?
- Explain the use of the 'this' and 'super' keywords.
- What is a static keyword in Java? When and why is it used?
- What are the differences between method overloading and method overriding?
Selenium Basics
- What is Selenium? Explain its components (Selenium IDE, WebDriver, Grid).
- What are the advantages of using Selenium for automation testing?
- What are the different types of locators in Selenium? Examples of id, name, className,
tagName, linkText, partialLinkText, xpath, and cssSelector.
- How do you handle dropdowns in Selenium WebDriver? Explain with an example using
the Select class.
- What is the difference between driver.get() and driver.navigate()?
- How do you handle multiple windows in Selenium? Explain with an example using
getWindowHandles().
- What are implicit and explicit waits in Selenium? Differentiate between them and provide
use cases.
- How do you take screenshots in Selenium? Explain using TakesScreenshot interface.
- What is the use of the Actions class in Selenium? Provide examples of mouse and keyboard
actions.
- What are the limitations of Selenium?
Selenium with Java Practical Questions
- Write a Selenium script to open a browser and navigate to a URL.
- How do you locate elements using XPath in Selenium? Examples of absolute and relative
XPath.
- Write a script to automate the login functionality of a website.
- How do you handle alerts and pop-ups in Selenium? Explain with examples of accept,
dismiss, and getText.
- Explain how to upload a file in Selenium WebDriver. Example using sendKeys().
- Write a script to fetch all the links from a webpage.
- How do you perform browser navigation in Selenium? Examples of back, forward, refresh.
- How do you perform data-driven testing in Selenium? Explain using Apache POI or any
other library for reading Excel files.
- Write a script to validate a page title in Selenium.
- How do you maximize a browser window in Selenium? Provide the command.
Additional Questions
- What is TestNG, and how is it used in Selenium? Explain annotations like @Test,
@BeforeMethod, @AfterMethod, etc.
- How do you create a test suite in TestNG?
- What are the different ways to execute Selenium scripts? Examples include TestNG, Maven,
and Jenkins.
- How do you integrate Selenium with version control systems like Git?
- What are Page Object Model (POM) and Page Factory? Explain with an example.
Behavioral Questions
- Why do you want to pursue a career in QA automation?
- Describe a situation where you learned something new to solve a problem.
- How do you ensure the quality of your work?
- How would you handle tight deadlines during testing?
- What are your strengths and weaknesses related to testing?