Interview Preparation Guide: Selenium with Java, Playwright, and C#
1. Selenium with Java (Strong Focus)
Core Topics:
- Selenium WebDriver architecture and working
- Locators (XPath, CSS Selectors, ID, Name, ClassName)
- Waits: Implicit, Explicit, Fluent Waits
- Handling Alerts, Popups, Frames, Windows
- Actions Class, Robot Class
- Screenshot Capture
- File Upload/Download
Framework Design:
- Page Object Model (POM)
- TestNG Integration
- Maven for Build Management
- Extent Reports / Allure Reports
- Log4j / SLF4J Logging
- Data Driven Framework (Apache POI)
Advanced Topics:
- Selenium Grid
- Docker for Selenium Execution
- Jenkins CI/CD
- Git Version Control
- Cross-Browser Testing
- Exception Handling Strategies
2. Java Programming for Test Automation
Core Concepts:
- OOPs: Inheritance, Encapsulation, Abstraction, Polymorphism
- Collection Framework (List, Set, Map)
- Exception Handling
- Java I/O and File Handling
- Streams and Lambda Expressions
- Multithreading Basics
- Java 8 Features
Coding Practice:
- Reverse a string/number
- Remove duplicates from array
- Count frequency of words in a sentence
- File comparison
3. Playwright Basics (Node.js/C#)
Playwright Concepts:
- Installation and setup
- Browser Contexts and Pages
- Locators and Selectors
- Auto-waiting and Timeout Management
- Screenshots, Videos, and Traces
- Parallel Execution
- Page Object Model in Playwright
- API Testing support
Playwright with C#:
- NUnit Setup
- Writing simple test cases in C#
- PageObject support in Playwright C#
- Handling async/await
4. C# Programming Basics
Language Fundamentals:
- Variables, Data Types, Operators
- Loops and Conditionals
- Classes, Interfaces, Structs
- Collections: List, Dictionary
- File Handling
- Exception Handling
- Delegates and Events
- Async/Await programming
NUnit Basics:
- Test Setup and Teardown
- Assertions
- Test Fixtures
5. Sample Interview Questions and Detailed Answers
Selenium + Java:
Q1: What's the difference between findElement and findElements?
- findElement returns the first matching element and throws NoSuchElementException if nothing is
found.
- findElements returns a list of matching elements and returns an empty list if no elements are found.
Q2: Explain POM with an example.
- Page Object Model is a design pattern where every web page is represented by a separate class.
This class contains methods and elements of that page.
- Benefits: Reusability, maintainability, and readability.
- Example: A LoginPage class may have methods like enterUsername(), enterPassword(), and
clickLogin().
Q3: How do you handle synchronization?
- Use of waits:
- Implicit Wait: Applies globally.
- Explicit Wait: Waits for a certain condition like visibility or clickability.
- Fluent Wait: Customized wait with polling and ignored exceptions.
Q4: What are StaleElementReferenceException and how to fix it?
- Occurs when the referenced element is no longer present on the DOM or has been refreshed.
- Fix by re-locating the element before reuse or using appropriate waits.
Java:
Q1: What is the difference between HashMap and Hashtable?
- HashMap is not synchronized, allows one null key and multiple null values.
- Hashtable is synchronized and does not allow null keys or values.
Q2: What are functional interfaces?
- Interfaces with a single abstract method.
- Used in lambda expressions.
- Example: Runnable, Callable, Comparable.
Q3: How does garbage collection work in Java?
- JVM automatically deallocates memory by removing objects that are no longer referenced.
- Uses algorithms like Mark and Sweep or Generational GC.
Playwright:
Q1: How is Playwright different from Selenium?
- Auto-waits built in.
- Supports multiple languages.
- Handles frames, tabs, and events more smoothly.
- Faster execution, better debugging tools like Trace Viewer.
Q2: Explain the concept of browser context.
- A browser context is an isolated session, like a new incognito window.
- Useful for testing different users or roles in parallel.
Q3: How to handle dynamic locators in Playwright?
- Use flexible selectors like page.locator("text=Login") or regex.
- Use .first() or .nth(index) for index-based elements.
C#:
Q1: What is the difference between ref and out parameters?
- ref: Requires initialization before passing, both read and write.
- out: Doesn't require initialization, must be assigned in the method.
Q2: What are extension methods?
- Allows adding methods to existing types without modifying them.
- Defined as static methods in static classes using 'this' keyword.
Q3: How do you handle exceptions in C#?
- Using try-catch blocks. Optionally include finally for cleanup code.
6. Hands-On Practice Tasks
- Create Selenium Maven POM project with TestNG
- Convert Selenium tests to Playwright (Node.js or C#)
- Write a small C# program to read/write to a file
- Build a Page Object-based Playwright project with NUnit
7. Behavioral Questions
- Tell me about a time when you automated a complex scenario.
- How do you prioritize your test automation tasks?
- How do you handle last-minute requirement changes?
- How do you adapt to new technologies/tools?