Skip to content

These are notes from interview questions, that often appeared on mid/senior level interviews for SDET/Java Test Automation Engineer. Feel free to use!

reevee-codes/java-test-automation-interview-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 

Repository files navigation

🧠 Test Automation Interview Notes (Java-focused)

Last update: 14.10.2025

Notes I use to improve and to ask candidates about 🙂
Languages: 🇵🇱 / 🇬🇧


🧩 UI Automation

Selenium vs Selenide

  • Selenide
    • Better assertions
    • Reduced boilerplate
    • Automatic screenshots
    • Easier file upload
  • Selenium
    • More flexible and language-agnostic
    • Full control over WebDriver
    • Larger ecosystem and community
    • Preferred in multi-language or custom integrations

🔹 Summary (PL): Tam, gdzie wymagane są niestandardowe integracje i wsparcie w wielu językach, czyste Selenium jest praktyczniejszym wyborem. Selenide upraszcza pracę w Javie, ale kosztem elastyczności.


Playwright (JS) vs Selenium (Java)

  • Playwright
    • Faster and easier setup
    • Auto-waiting for elements
    • Built-in features (multi-tab, network mocking, cross-browser)
  • Selenium (Java)
    • Strong Java ecosystem (JUnit/TestNG, Maven/Gradle)
    • Long-term stability
    • Better enterprise adoption
    • Wider real-device and CI/CD integration

🔹 Summary (PL): Playwright JS bywa szybszy i wygodniejszy, ale Selenium ma większe wsparcie w środowiskach enterprise i stabilniejszą infrastrukturę CI/CD.


Page Object Patterns

  • Page Object Model (POM) → separates page structure from test logic.
  • Page Factory → initializes elements via annotations.
  • Fluent POM → chainable methods for readable and expressive test steps.

💻 Computer Science

Concurrency vs Parallelism

  • Concurrency → tasks appear to run at the same time (context switching).
    Example: Switching between threads.
  • Parallelism → tasks actually run at the same time on multiple CPU cores.

⚙️ Selenium Essentials

Find Element(s)

Method Returns On Failure
findElement() Single element Throws NoSuchElementException
findElements() List of elements Returns empty list

Waits

  • Implicit Wait → applied globally, waits for all elements.
  • Explicit Wait → waits for a specific condition for a specific element.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("example")));

Browser Invocation

System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://example.com");

TestNG

  • Easier to use than JUnit (especially JUnit 4)
  • Supports parallel testing
  • Supports grouping, dependencies, and data providers

Reading Excel Files

  • Use Apache POI library for .xls / .xlsx manipulation.

Parallel Testing in TestNG

  • parallel="methods" → runs test methods in parallel
  • parallel="classes" → runs all methods in a class together
  • parallel="tests" → runs test groups in parallel

Common Selenium Exceptions

  • ElementNotSelectableException
  • ElementNotVisibleException
  • NoSuchFrameException
  • NoSuchWindowException
  • StaleElementReferenceException → element no longer attached to DOM

Handling Alerts / Frames

driver.switchTo().alert().accept();
driver.switchTo().frame("frameId");

Soft vs Hard Assertions

  • Hard Assert → stops test immediately when failed
  • Soft Assert → continues test execution after failure

☕ Java

Access Modifiers

Modifier Class Package Subclass Global
public
protected
default
private

Checked vs Unchecked Exceptions

  • Checked (compile-time): IOException, SQLException, FileNotFoundException
  • Unchecked (runtime): NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticException

Exception Handling

Question: Which exception you shouldn’t handle?
Answer: You generally shouldn’t handle Error or RuntimeException types like OutOfMemoryError, StackOverflowError, or VirtualMachineError. These indicate serious issues in the JVM or the environment that your application cannot recover from.
Focus on handling only exceptions you can gracefully recover from or log for troubleshooting (e.g. IOException, TimeoutException).


Web and Selenium Questions

1. What is robots.txt?
A file that tells search engine crawlers which pages or files the crawler can or cannot request from your site.

2. How to rerun failing tests in Maven?
Add this to your pom.xml:

<rerunFailingTestsCount>1</rerunFailingTestsCount>

Or use Surefire/Failsafe plugin configuration for automatic reruns.

What is StaleElementReferenceException?
Occurs when the referenced element is no longer attached to the DOM (after reload or AJAX update).
Solution: Re-locate the element after DOM change.

Locator absolute vs relative:

  • Absolute XPath: Starts from the root (/html/body/...), breaks easily.
  • Relative XPath: Starts from any node using //, more stable.

How to handle dynamic locators:
Use CSS patterns, XPath functions like contains(), or attributes that remain stable (e.g. data-* attributes).

Can you take a screenshot in Selenium?
Yes, using TakesScreenshot interface:

File file = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

What does headless mode mean?
Browser runs without GUI; faster and suitable for CI/CD pipelines.

How to retry failed tests:
Use TestNG retry analyzer or JUnit retry logic, or rerun configuration in build tools.

How do you check code coverage in test automation?
Use JaCoCo or SonarQube to measure unit and integration test coverage.

Switching between tabs/windows in Selenium:

String originalWindow = driver.getWindowHandle();
for (String handle : driver.getWindowHandles()) {
    driver.switchTo().window(handle);
}

Selenium vs Selenide:

  • Selenide is a wrapper around Selenium simplifying waits, browser control, and reporting.

Driver management design:
Use Singleton or Factory Pattern to initialize and manage drivers centrally.

UI testing framework design:
Modular design (BasePage, PageObjects, Utils, TestBase), parallel execution setup, and reporting integration.

Design patterns in UI testing:

  • Page Object Model (POM)
  • Factory Pattern
  • Singleton Pattern
  • Strategy Pattern

Handling dynamic elements:
Use explicit waits (WebDriverWait) or dynamic locators.

Parallel test execution:
Configure <forkCount> or threads in Surefire/TestNG for multithreading.

Testing dataLayer:
Use browser devtools protocol or JavaScriptExecutor to read dataLayer objects.

What’s the biggest problem you faced at work and how did you solve it?
(Be prepared with a STAR example.)

What’s something new you’ve learned recently?
Example: Healenium integration, AI in testing, or Playwright with Java.

Boolean vs boolean:

  • boolean: primitive type (default false).
  • Boolean: wrapper class (can be null).

Defensive Programming:
Write code assuming it will fail — validate inputs, handle exceptions safely.

Extreme Programming (XP):
Agile methodology focusing on frequent releases, pair programming, and continuous feedback.

Sharing data between Gherkin steps:
Use dependency injection (like PicoContainer) or a TestContext class.

25. Maintaining large test suites:
Modularize, run smoke suites daily, optimize test data, and track flaky tests.

26. How to test microservices:
Use integration tests, contract tests, and E2E tests. Use Docker/K8s for isolation.

27. Git merge vs rebase:

  • Merge: preserves history (safe for teams).
  • Rebase: cleaner history, but riskier (modifies commits).

28. Why rebase is risky:
It rewrites commit history, can cause loss of context or merge conflicts.

29. Git reflog:
Tracks all Git actions, even detached heads or rebases. Helps recover lost commits.

30. Concurrency vs Parallelism:

  • Concurrency: Tasks start, run, and finish in overlapping times.
  • Parallelism: Tasks run at the same time on multiple cores.

31. Git hooks:
Scripts triggered on Git actions (pre-commit, post-merge, etc.)

32. Docker Registry:
A repository for Docker images (like Docker Hub). Stores and distributes container images.


3. Load and Performance Testing

What is load testing and why is it important?
Measures how the system behaves under expected load. Detects bottlenecks and ensures scalability.

JMeter basics:

  • Thread Group (users, ramp-up, loops)
  • HTTP Request
  • Listeners (results, graphs)

4. Java and OOP

Newest Java Version: 22 (LTS: 21)
Key changes: pattern matching, record patterns, performance and security improvements.

Data Structures: Lists, Sets, Maps, Queues, Stacks — choose based on lookup, insertion, and ordering needs.

Recursion: Used for hierarchical structures (trees, graphs).

Design Patterns used in projects:
Singleton, Factory, Builder, POM, Strategy.

Testing multi-threaded code:
Use synchronization, mocks, and concurrency testing frameworks.

Defensive Programming:
Anticipate failure and validate inputs.

Method Override vs Overload:

  • Override: same method signature in subclass.
  • Overload: same method name, different parameters.

HashMap keys:
Must properly implement hashCode() and equals() for consistent key lookup.


5. Framework and Architecture

Common framework problems:

  • Flaky tests
  • Slow execution
  • Poor test data management
  • Hard-to-maintain locators
  • Lack of modularity or CI integration

Framework creation experience:
Yes — modular, scalable architecture using POM, TestNG/Cucumber, CI integration, and reporting.


About

These are notes from interview questions, that often appeared on mid/senior level interviews for SDET/Java Test Automation Engineer. Feel free to use!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published