Skip to content

Automation Testing Intern Interview Questions & Answers

40 questions for Automation Testing Intern interviews — 25 easy, 15 medium.

About the Automation Testing Intern role

Supports the QA team by writing simple automated tests, updating locators, running suites and reporting results, while learning the framework. Interviews check basic Java (OOP, strings, collections), Selenium fundamentals, common TestNG annotations, manual testing concepts and willingness to learn. A small personal project on GitHub makes a strong impression at this level.

Core Java basics Selenium basics TestNG annotations Git basics Bug reporting
Solved for this roleStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

String vs StringBuilder?

Save to ▾
Show answer
String is immutable — every change creates a new object. StringBuilder is mutable and faster for repeated changes (not thread-safe; StringBuffer is).
02

How do you test that a method throws an expected exception in TestNG?

Save to ▾
Show answer
Use @Test(expectedExceptions = IllegalArgumentException.class) and optionally expectedExceptionsMessageRegExp to check the message. The test passes only if that exception is thrown. For more control, use Assert.assertThrows(IllegalArgumentException.class, () -> service.withdraw(-5)), which returns the exception so you can inspect it further. This style is clearer because the check applies to one line, not the whole test.
03

A TestNG test passes when run alone but fails when the full class runs. What do you check?

Save to ▾
Show answer
Look for shared state between methods: instance or static fields changed by earlier tests, data created or deleted by another test, cookies or logged-in session kept in the same browser, and priority or order assumptions. Run the class in a different order to confirm. Fix by resetting state in @BeforeMethod, creating unique data per test and avoiding static fields.
04

Your Selenium tests in CI produce blank screenshots in headless mode. What could be wrong?

Save to ▾
Show answer
The screenshot may be taken before the page renders, the window size in headless mode may be tiny, or the browser is crashing due to low shared memory in Docker. Set --window-size=1920,1080, use the new headless mode, wait for page content before capturing, and add --disable-dev-shm-usage or a larger shm size for containers.
05

Describe a time you convinced developers to fix a problem found by automation.

Save to ▾
Show answer
Situation: an API test kept failing intermittently and developers called it a test issue. Task: prove or disprove it. Action: I collected logs from ten failures, showed the same race condition in the order service with request IDs, and reproduced it with a small parallel script. Result: developers fixed a real concurrency bug before it reached customers, and trust in the suite improved.
06

What is the difference between getText() and getAttribute()?

Save to ▾
Show answer
getText returns visible inner text; getAttribute returns an HTML attribute or property such as value, href or class.
07

Implicit vs explicit vs fluent wait?

Save to ▾
Show answer
Implicit wait applies globally to element lookups. Explicit wait waits for a specific condition (WebDriverWait + ExpectedConditions). Fluent wait is an explicit wait with custom polling and ignored exceptions.
08

Why do you want to work as an automation tester rather than a manual tester?

Save to ▾
Show answer
Situation: in my internship I repeated the same regression checks every release. Task: I wanted to free time for exploratory testing. Action: I learnt Selenium and Java and automated our login and search regression in my spare time. Result: the checks went from two hours to ten minutes, and I realised I enjoy building tools that improve quality, which is why I want this role.
09

What are wrapper classes in Java?

Save to ▾
Show answer
Classes such as Integer and Double that wrap primitive types as objects, needed for collections and for parsing text from web elements.
10

Write Java code to find the second largest number in an integer array.

Save to ▾
Show answer
public static int secondLargest(int[] nums) { int first = Integer.MIN_VALUE, second = Integer.MIN_VALUE; for (int n : nums) { if (n > first) { second = first; first = n; } else if (n > second && n != first) { second = n; } } if (second == Integer.MIN_VALUE) throw new IllegalArgumentException("No second largest"); return second; }
11

A test fails with TimeoutException waiting for an element that is clearly visible on screen. What do you check?

Save to ▾
Show answer
Check whether the element is inside an iframe or shadow DOM, the locator matches a different hidden element first, the page opened in a new tab not yet switched to, or the wait condition is wrong, such as presence versus visibility versus clickable. Use findElements to see how many matches the locator has and verify it in browser DevTools.
12

How do you scroll a page in Selenium?

Save to ▾
Show answer
Use JavascriptExecutor with window.scrollTo or scrollIntoView, or the Actions class scroll methods in Selenium 4.
13

What is the execution order of TestNG annotations?

Save to ▾
Show answer
@BeforeSuite → @BeforeTest → @BeforeClass → @BeforeMethod → @Test → @AfterMethod → @AfterClass → @AfterTest → @AfterSuite.
14

What is TestNG and why is it used with Selenium?

Save to ▾
Show answer
A test framework offering annotations, grouping, prioritisation, parallel runs, data providers and reports, which structure and scale Selenium tests.
15

ArrayList vs HashMap — how do you use them in a framework?

Save to ▾
Show answer
ArrayList stores an ordered list (e.g. all product names on a page). HashMap stores key–value pairs (e.g. test data or config properties).
16

Method overloading vs overriding?

Save to ▾
Show answer
Overloading: same method name, different parameters, in the same class (compile time). Overriding: a subclass redefines a parent method with the same signature (runtime polymorphism). WebDriver driver = new ChromeDriver() is runtime polymorphism.
17

Write Java code to find duplicate elements in a list.

Save to ▾
Show answer
List<String> names = List.of("Asha", "Ravi", "Asha", "Neha", "Ravi"); Set<String> seen = new HashSet<>(); Set<String> dupes = new LinkedHashSet<>(); for (String n : names) { if (!seen.add(n)) { dupes.add(n); } } System.out.println(dupes); // [Asha, Ravi]
18

What are exceptions and how do you handle them?

Save to ▾
Show answer
Runtime events that disrupt flow. Use try-catch-finally, throw, throws, and custom exceptions; checked exceptions must be handled while unchecked ones need not be.
19

Selenium's driver version suddenly mismatches the browser version on agents. How do you prevent this?

Save to ▾
Show answer
Use Selenium Manager, built into Selenium 4.6 and later, which resolves the right driver automatically, so you do not commit driver binaries. In CI, pin browser versions using Docker images or browser options so all agents match. Avoid auto-updating browsers on test agents. Log the browser and driver versions at the start of each run to diagnose quickly.
20

How do you run the same test with data from Excel using a DataProvider?

Save to ▾
Show answer
Write a utility that reads the sheet with Apache POI and returns Object[][] with one row per test case. Create a @DataProvider method that calls the utility, and set dataProvider = "loginData" on the test. Each row runs as a separate test with its own result. Keep the file in src/test/resources and consider CSV or JSON, which are easier to review in Git.
21

How do you handle a browser basic authentication pop-up in Selenium?

Save to ▾
Show answer
The basic auth dialog is not part of the page, so findElement cannot reach it. The simplest way is putting credentials in the URL, like https://user:pass@site.test, which works in many browsers. In Selenium 4 with Chromium you can register credentials through the HasAuthentication interface: ((HasAuthentication) driver).register(UsernameAndPassword.of("user", "pass")). Keep the credentials in environment variables or a secret store, never in code.
22

What is the timeOut attribute in TestNG?

Save to ▾
Show answer
@Test(timeOut = 5000) fails the test if it runs longer than 5000 milliseconds. It can also be set at suite or test level in testng.xml. It protects pipelines from hanging tests, for example a stuck network call. It is not a performance test; use reasonable limits so slow but correct environments do not cause false failures.
23

Write Selenium code to wait for a loader to disappear and then click a button.

Save to ▾
Show answer
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); wait.until(ExpectedConditions.invisibilityOfElementLocated( By.cssSelector(".spinner"))); wait.until(ExpectedConditions.elementToBeClickable( By.id("placeOrder"))).click();
24

Tell me about a time you had to learn Java quickly for an automation role.

Save to ▾
Show answer
Situation: I moved from manual testing into an automation team using Java. Task: become productive within a month. Action: I practised core Java daily, focusing on OOP, collections and exceptions, solved small coding problems, and read the existing framework code with a senior's help. Result: in four weeks I was writing page objects and tests that passed review, and I kept learning streams afterwards.
25

How do you handle dropdowns in Selenium?

Save to ▾
Show answer
Use the Select class with selectByVisibleText, selectByValue or selectByIndex; for custom dropdowns click and choose from the list of elements.
26

Write Java code to count the occurrences of each character in a string.

Save to ▾
Show answer
String s = "automation"; Map<Character, Integer> counts = new LinkedHashMap<>(); for (char c : s.toCharArray()) { counts.put(c, counts.getOrDefault(c, 0) + 1); } System.out.println(counts); // a=2, u=1, t=2, o=2, m=1, i=1, n=1
27

How do you include and exclude groups in testng.xml?

Save to ▾
Show answer
Inside a <test>, add <groups><run><include name="smoke"/><exclude name="broken"/></run></groups>. Only methods in the included groups run, minus excluded ones. Configuration methods must have alwaysRun = true or belong to the groups, or they will be skipped. You can also pass -Dgroups=smoke from Maven Surefire for CI selection.
28

What are try-with-resources and why use them?

Save to ▾
Show answer
A try block that automatically closes resources such as file readers or streams, preventing leaks without a finally block.
29

How did you handle it when your test estimates turned out to be wrong in a sprint?

Save to ▾
Show answer
Situation: I estimated three days to automate a new module, but the UI had complex dynamic tables. Task: still deliver what the sprint needed. Action: I told the lead early on day two, proposed automating the API checks first and the UI flows next sprint, and documented the extra effort. Result: the sprint goal was met, and I now spike unfamiliar screens before estimating.
30

An assertion on element text fails even though the text looks identical on screen. What could be the reason?

Save to ▾
Show answer
The text may contain extra whitespace, a line break or a non-breaking space that looks normal visually. getText() also returns only visible text and applies CSS text-transform, so uppercase styling changes the value. Print the string with its length or character codes to spot hidden characters. Fix it by trimming and normalising whitespace before comparing, or compare with the expected case-insensitively when the UI uses text-transform.
31

What is method overriding and where is it useful in frameworks?

Save to ▾
Show answer
A subclass redefines a parent method. Frameworks use it to customise base behaviour, such as overriding a wait or click method in a base page class.
32

Reverse a string in Java.

Save to ▾
Show answer
String r = new StringBuilder(s).reverse().toString(); // or loop from the last index and append each character
33

What is Selenium Grid and why use it?

Save to ▾
Show answer
It runs tests in parallel across multiple machines and browsers using a hub and nodes, cutting execution time and increasing browser coverage.
34

What is WebDriver and how does it communicate with the browser?

Save to ▾
Show answer
WebDriver sends commands over HTTP (W3C protocol) to a browser-specific driver such as chromedriver, which controls the actual browser.
35

How does HashMap work internally?

Save to ▾
Show answer
It uses the key's hashCode to find a bucket and equals to resolve collisions, giving O(1) average lookups; Java 8 converts long buckets into trees.
36

What locators does Selenium support?

Save to ▾
Show answer
id, name, className, tagName, linkText, partialLinkText, CSS selector and XPath. Prefer stable ids or CSS, using XPath when needed.
37

What new features came with Selenium 4?

Save to ▾
Show answer
Relative locators, improved Grid, W3C compliance, new window or tab creation, Chrome DevTools Protocol access and element-level screenshots.
38

What is the purpose of testng.xml?

Save to ▾
Show answer
A configuration file to define suites, tests, classes, groups, parameters and parallel execution settings.
39

How do you handle alerts and pop-ups?

Save to ▾
Show answer
driver.switchTo().alert() lets you accept, dismiss, read text or send keys. Browser windows are handled with window handles.
40

A teammate compares two strings with == and the test sometimes passes and sometimes fails. Explain.

Save to ▾
Show answer
== compares object references, not content. String literals are interned, so two literals with the same text may share a reference and == returns true, but strings read from the UI or built at runtime are new objects, so == returns false even with the same text. Use equals() or equalsIgnoreCase() for content, and Objects.equals() to be null-safe.

Frequently asked questions

What does a Automation Testing Intern do?

Supports the QA team by writing simple automated tests, updating locators, running suites and reporting results, while learning the framework. Interviews check basic Java (OOP, strings, collections), Selenium fundamentals, common TestNG annotations, manual testing concepts and willingness to learn. A small personal project on GitHub makes a strong impression at this level.

Which skills are tested in a Automation Testing Intern interview?

Expect questions on Core Java basics, Selenium basics, TestNG annotations, Git basics, Bug reporting. Most rounds also ask you to explain a project and solve one practical problem live.

How do I prepare for a Automation Testing Intern interview?

Revise Core Java for Testers, Selenium WebDriver, TestNG Framework first using the topic sheets, practise the questions on this page aloud, then do one full mock interview to practise timing.