First Scripts • XPath • Browser Actions • TestNG Basics • Small Programs • 2026

Selenium Interview Questions for Freshers

Selenium fresher rounds check whether you can explain the basics in your own words: what Selenium is and is not, how to write a first script, XPath by hand, reading and checking elements, simple TestNG and the exceptions you will meet. Then comes a small program, like printing a table column or finding broken links, and questions about the project on your resume. It is written for final-year students, new graduates and anyone coming out of an internship or a testing course who is facing a first Selenium interview. Each question shows what the interviewer is checking, the shape of a good answer and a short answer to say out loud. Examples are in Java.

Search all questions by round, difficulty and level, or save the ones you want to practice.

Selenium Basics 3 questions

Easy Technical round Fresher Practice question

1. What is Selenium, and what are the different tools that make up the Selenium project?

What the interviewer is really testing:
Whether you know Selenium is a family of tools for automating browsers, and which part you actually use when you write tests.
Answer frame:

One line: an open-source project for automating web browsers.

Three tools: WebDriver for coded tests, IDE for record and playback, Grid for running on many machines.

What you use: WebDriver with a language binding, plus a test runner like TestNG.

Sample spoken answer:

“Selenium is an open-source project for automating web browsers, mostly used to test web applications. It has three main tools. WebDriver is the one I use most: it's a library that lets my code drive a real browser, and it has bindings for Java, Python, C#, JavaScript and Ruby. Selenium IDE is a browser extension that records your clicks and plays them back, which is handy for a quick demo but not for a real suite. Selenium Grid lets you run tests on several machines and browsers at once. On its own Selenium only drives the browser, so for checks and reports I pair it with TestNG, and I use Maven to pull in the libraries. In my project that was Java, WebDriver, TestNG and Maven.”

Red flag to avoid:

Calling Selenium a testing tool that has assertions and reports built in, or not knowing that WebDriver is the part you code against.

They may ask next:
  • What was Selenium RC, and why don't people use it any more?
  • Why is Selenium IDE not enough for a real regression suite?
Say it in 60 seconds
Easy Technical round Fresher Practice question

2. What can't Selenium test on its own? Give me a few things you'd need another tool or a manual check for.

What the interviewer is really testing:
Whether you know the limits of the tool, so you won't promise to automate things like captchas or desktop apps.
Answer frame:

Scope: only web pages inside a browser.

Hard limits: captcha, desktop apps, native mobile apps, image-level visual checks.

Missing pieces: no built-in assertions, reports or test data, so you add libraries.

Sample spoken answer:

“Selenium only works with web pages inside a browser, so anything outside that is out of reach. It can't automate a Windows or Mac desktop app, or a native mobile app on its own; for mobile people use Appium, which builds on the same WebDriver idea. A captcha is meant to block bots, so we either get a test bypass from the developers or test it by hand. An OTP sent to a real phone is the same story. Selenium also can't judge how a page looks, like a broken layout or a wrong image, unless you add a visual testing tool. And it has no assertions, reports or test data handling built in, which is why I pair it with TestNG and a reporting library.”

Red flag to avoid:

Claiming Selenium can automate anything on the screen, including captchas and desktop windows.

They may ask next:
  • How would you handle a captcha on the login page of the app you are testing?
  • Can Selenium handle the Windows file picker dialog? What do people do instead?
Say it in 60 seconds
Medium Technical round Fresher Practice question

3. What changed in Selenium 4 that you have used or read about? Show me one of the new features in code.

What the interviewer is really testing:
Whether your learning is current, and you can name a few real changes rather than repeating old tutorials.
Answer frame:

Protocol: talks to browsers using the W3C WebDriver standard.

New helpers: relative locators, opening a new tab or window, element screenshots.

Also: Chrome DevTools access for Chromium browsers, a redesigned Grid.

Sample spoken answer:

“The biggest change underneath is that Selenium 4 talks to browsers using the W3C WebDriver standard, so the commands mean the same thing in every browser. The things I've actually used are relative locators, where I can say find the input below the email field or to the right of a label, using RelativeLocator.with and methods like below, above, toLeftOf, toRightOf and near. I've also used switchTo().newWindow to open a fresh tab without a keyboard shortcut, and taking a screenshot of just one element instead of the whole page. It also added access to Chrome DevTools for Chromium browsers and a redesigned Grid. Relative locators are nice, but I still prefer a stable id when there is one.”

Code:
WebElement password = driver.findElement(
        RelativeLocator.with(By.tagName("input")).below(By.id("email")));

driver.switchTo().newWindow(WindowType.TAB);

File logoShot = logo.getScreenshotAs(OutputType.FILE);
Red flag to avoid:

Only knowing tutorials that still set driver paths and use old APIs, with no idea anything changed.

They may ask next:
  • When could a relative locator pick the wrong element?
  • What was the old way to open a new tab before newWindow existed?
Say it in 60 seconds

Coding Tasks 4 questions

Easy Coding round Fresher Practice question

4. Write a small Selenium program that opens a browser, goes to a website, prints the page title and closes the browser.

What the interviewer is really testing:
Whether you can write a complete, working script from memory, including the imports and closing the browser even if something fails.
Answer frame:

Start: create a ChromeDriver, which launches the browser.

Act: driver.get with the URL, then driver.getTitle.

Clean up: quit inside finally so the browser never stays open.

Sample spoken answer:

“I create a WebDriver by calling new ChromeDriver, which opens a Chrome window. Recent Selenium 4 versions find or download the matching driver by themselves, so I don't need to set a driver path the old way. Then driver.get opens the URL and waits for the page to load, and driver.getTitle gives me the text in the title tag, which I print. I put quit in a finally block, so even if the page fails to load or an exception is thrown, the browser and the driver process are closed. In a real test I'd move the setup and quit into TestNG before and after methods and use an assertion instead of printing, but for a first script this is the whole thing.”

Code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class FirstTest {
    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://example.com");
            System.out.println("Title: " + driver.getTitle());
        } finally {
            driver.quit();
        }
    }
}
Red flag to avoid:

Forgetting to close the browser, or not knowing which class you import to start Chrome.

They may ask next:
  • How would you turn this into a TestNG test that checks the title instead of printing it?
  • How would you make the same program run on Firefox?
Say it in 60 seconds
Medium Coding round Fresher Practice question

5. A page has an HTML table of users. Write code to print how many rows it has and every value in the second column.

What the interviewer is really testing:
Whether you can combine findElements, a loop and a locator for table cells, a very common fresher whiteboard task.
Answer frame:

Locate cells: an XPath or CSS for td elements in the second position inside tbody.

Loop: findElements gives a list; print getText for each.

Watch out: header cells are th, and some tables have no tbody in the source.

Sample spoken answer:

“I'd use findElements with an XPath that picks the second td in every row of the table body: //table[@id='users']/tbody/tr/td[2]. That returns a list, so its size is the number of data rows, as long as every row has a second cell, and I loop over it and print getText for each cell. Using tbody skips the header row, because headers are usually th cells in thead anyway. If the table has no id I'd anchor on a nearby heading or a class. One detail worth knowing: browsers add a tbody even if the HTML doesn't have one, so the XPath still works. If I needed a whole row at a time, I'd get the tr elements first and then call findElements on each row for its cells.”

Code:
List<WebElement> rows = driver.findElements(By.xpath("//table[@id='users']/tbody/tr"));
System.out.println("Rows: " + rows.size());

List<WebElement> cells = driver.findElements(
        By.xpath("//table[@id='users']/tbody/tr/td[2]"));
for (WebElement cell : cells) {
    System.out.println(cell.getText());
}
Red flag to avoid:

Using findElement in a loop with hard-coded row numbers, or not knowing XPath indexes start at 1.

They may ask next:
  • How would you find the row where the second column equals a given name and print its first column?
  • What changes if the table loads more rows when you scroll or click Next?
Say it in 60 seconds
Hard Coding round Fresher Practice question

6. Write a Selenium program to find every broken link on a page. Can Selenium tell you a link is broken on its own?

What the interviewer is really testing:
Whether you know Selenium cannot read HTTP status codes, and can combine it with a plain HTTP call to check each link.
Answer frame:

Collect: findElements on anchor tags, read each href.

Filter: skip empty, mailto and javascript links.

Check: send an HTTP request per link; a status of 400 or above means broken.

Sample spoken answer:

“Selenium can't see status codes; it only sees the page the browser shows. So I use Selenium to collect the links and plain Java to check them. First I find all a tags and read the href of each. I skip the ones that are empty or don't start with http, like mailto or javascript links. For each remaining URL I open an HttpURLConnection, send a HEAD request because I only need the status, and read the response code. Anything 400 or above, like a 404 Not Found or a 500 error, I print as broken. I set a timeout so one dead server doesn't hang the whole run. A few servers reject HEAD, so if I get a 405 I'd retry that link with GET before calling it broken.”

Code:
List<WebElement> links = driver.findElements(By.tagName("a"));
for (WebElement link : links) {
    String href = link.getAttribute("href");
    if (href == null || !href.startsWith("http")) {
        continue;
    }
    HttpURLConnection conn = (HttpURLConnection) URI.create(href).toURL().openConnection();
    conn.setRequestMethod("HEAD");
    conn.setConnectTimeout(5000);
    conn.setReadTimeout(5000);
    int status = conn.getResponseCode();
    if (status >= 400) {
        System.out.println("Broken: " + href + " -> " + status);
    }
    conn.disconnect();
}
Red flag to avoid:

Clicking every link and checking the page title, or claiming Selenium returns the HTTP status.

They may ask next:
  • How would you check broken images on the same page?
  • The page has three hundred links and the check is slow. How would you speed it up?
Say it in 60 seconds
Hard Coding round Fresher Practice question

7. Automate this: type laptop into a search box, press Enter, wait for the results, and check that every result title contains the word.

What the interviewer is really testing:
Whether you can write a complete small test with waits, keyboard input, a loop and assertions, and catch the edge cases.
Answer frame:

Type and submit: wait for the box, clear it, sendKeys with Keys.ENTER.

Wait for results: visibility of all result titles, not a sleep.

Check: fail if there are none, then compare each title ignoring case.

Sample spoken answer:

“I'd wait for the search box to be clickable, clear it, and send the word with Keys.ENTER in the same sendKeys call, which presses Enter after typing. Then I'd wait until the result titles are visible instead of sleeping. That wait only returns once at least one title is showing, so an empty results page fails with a timeout rather than passing. I still keep the not-empty assert with a clear message, because a loop over zero results passes without checking anything, and that bug would come back if someone later swapped the wait for a plain findElements. Then for each title I lower-case the text and assert it contains laptop, with a message that prints the bad title. If the old results stay on screen during a new search, I'd first wait for the old list to go stale, so I don't check the old results.”

Code:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement box = wait.until(ExpectedConditions.elementToBeClickable(By.name("q")));
box.clear();
box.sendKeys("laptop", Keys.ENTER);

List<WebElement> titles = wait.until(ExpectedConditions
        .visibilityOfAllElementsLocatedBy(By.cssSelector(".result .title")));
Assert.assertFalse(titles.isEmpty(), "No results shown");
for (WebElement t : titles) {
    Assert.assertTrue(t.getText().toLowerCase().contains("laptop"),
            "Title without the word: " + t.getText());
}
Red flag to avoid:

Looping over the results without first checking the list is not empty.

They may ask next:
  • Would you use a soft assert here? Why or why not?
  • How would you test the case where the search finds nothing?
Say it in 60 seconds

Browser Actions 5 questions

Easy Technical round Fresher Practice question

8. What is the difference between driver.get() and driver.navigate().to()? How do you go back, forward or refresh?

What the interviewer is really testing:
Whether you know the navigation methods and avoid the common myth that one of them does not wait for the page.
Answer frame:

Loading a URL: both open the page and wait for it to load in the same way.

The difference: navigate() also gives back, forward and refresh.

The myth: saying navigate().to() skips the wait is wrong.

Sample spoken answer:

“Both driver.get and driver.navigate().to open a URL, and both wait for the page to finish loading before the next line runs. In practice navigate().to is just another way to call the same thing. The real difference is that navigate gives you the browser's history buttons too: navigate().back(), navigate().forward() and navigate().refresh(). So I use get to open the first page in a test because it reads simply, and navigate when I need to go back to the list after opening a detail page, or refresh to check that a saved value is still there after reload. A lot of people say navigate doesn't wait for the page, but that's not true.”

Code:
driver.get("https://shop.example.com/products");
driver.findElement(By.linkText("Blue Kettle")).click();
driver.navigate().back();     // returns to the product list
driver.navigate().forward();
driver.navigate().refresh();
Red flag to avoid:

Saying navigate().to() does not wait for the page load while get() does.

They may ask next:
  • After navigate().back(), why might an element you stored before throw an exception?
  • How would you check which URL you ended up on after a click?
Say it in 60 seconds
Easy Technical round Fresher Practice question

9. You type a name into an input box and then call getText() on it, but it returns an empty string. Why, and how do you read the value?

What the interviewer is really testing:
Whether you know the difference between an element's visible text and an input's value, a mistake almost every beginner makes.
Answer frame:

getText: returns the visible text between the tags.

Inputs: what you type lives in the value property, not in the text.

Fix: read getAttribute("value"), or getDomProperty("value") in Selenium 4.

Sample spoken answer:

“getText returns the visible text inside an element, the text between its opening and closing tags, like the words on a button or in a paragraph. An input box has no text between tags; what you type is stored in its value property. So getText on an input comes back empty, and that's expected. To read what's in the box I call getAttribute with value, and in Selenium 4 I can also use getDomProperty with value, which reads the live property directly. I hit this in my college project when checking that a form kept the name after a page error: the check kept failing until I switched from getText to reading the value. Also, getText only returns text that's actually visible, so hidden text comes back empty as well.”

Code:
WebElement name = driver.findElement(By.id("name"));
name.sendKeys("Asha");
name.getText();                // "" for an input box
name.getAttribute("value");    // "Asha"
name.getDomProperty("value");  // "Asha"
Red flag to avoid:

Assuming getText is broken, or not knowing where a typed value is stored.

They may ask next:
  • How would you read the selected text of a dropdown?
  • How would you check that a text box shows a placeholder hint?
Say it in 60 seconds
Easy Technical round Fresher Practice question

10. How do you check that a checkbox is ticked, a button is enabled and a message is visible? What happens if the element is not on the page at all?

What the interviewer is really testing:
Whether you know isSelected, isEnabled and isDisplayed, and the trap that they throw rather than return false when the element is missing.
Answer frame:

Three methods: isSelected for checkboxes and radios, isEnabled for buttons and fields, isDisplayed for visibility.

Trap: they need the element to exist; a missing element throws NoSuchElementException.

Checking absence: use findElements and check the list is empty.

Sample spoken answer:

“WebElement has three state methods. isSelected tells me whether a checkbox or radio button is ticked, isEnabled tells me whether a button or field can be used, and isDisplayed tells me whether the element is visible on the page. All three return true or false. The catch is that I have to find the element first. If it's not in the page at all, findElement throws NoSuchElementException before isDisplayed ever runs, so isDisplayed never gets the chance to return false. When I want to check that something is gone, like an error message after fixing a field, I use findElements, which returns an empty list instead of throwing, and assert the list is empty. Before ticking a checkbox I check isSelected first, so I don't untick one that's already on.”

Code:
WebElement terms = driver.findElement(By.id("terms"));
if (!terms.isSelected()) {
    terms.click();
}
Assert.assertTrue(driver.findElement(By.id("submit")).isEnabled());
Assert.assertTrue(driver.findElements(By.cssSelector(".error")).isEmpty());
Red flag to avoid:

Believing isDisplayed returns false for an element that is not in the page at all.

They may ask next:
  • How would you wait for a message to disappear instead of checking once?
  • Can isSelected tell you which option is chosen in a dropdown?
Say it in 60 seconds
Medium Technical round Fresher Practice question

11. How do you hover over a menu, double-click, right-click or drag and drop an element in Selenium?

What the interviewer is really testing:
Whether you know the Actions class for mouse gestures that a plain click cannot do.
Answer frame:

Tool: the Actions class, built with the driver.

Methods: moveToElement, doubleClick, contextClick, dragAndDrop.

Must do: end with perform(), or nothing happens.

Sample spoken answer:

“For anything beyond a simple click I use the Actions class. I create it with new Actions(driver), then chain the gesture and finish with perform. moveToElement hovers, which I need for menus that only open on hover; after hovering I wait for the submenu and click the item. doubleClick and contextClick do a double click and a right click. dragAndDrop takes a source and a target element. The most common mistake is forgetting perform, because then the actions are only built, not sent to the browser. I used dragAndDrop in a project to move cards on a board, and learned that on some pages built with HTML5 drag and drop it doesn't work, and people fall back to a JavaScript workaround.”

Code:
Actions actions = new Actions(driver);
actions.moveToElement(accountMenu).perform();
actions.doubleClick(row).perform();
actions.contextClick(fileIcon).perform();
actions.dragAndDrop(card, doneColumn).perform();
Red flag to avoid:

Leaving out perform(), or trying to hover by calling click on the menu.

They may ask next:
  • How would you type a capital letter by holding Shift with the Actions class?
  • What is the difference between build() and perform()?
Say it in 60 seconds
Medium Technical round Fresher Practice question

12. How do you read, add and delete cookies with Selenium, and how could cookies make your tests faster?

What the interviewer is really testing:
Whether you know the cookie methods on driver.manage() and the rule that you must be on the site's domain before adding one.
Answer frame:

Methods: getCookies, getCookieNamed, addCookie, deleteCookieNamed, deleteAllCookies.

Rule: open a page on that domain before adding a cookie.

Use: add a session cookie to skip the login screen in tests that are not about login.

Sample spoken answer:

“Cookies are handled through driver.manage(). getCookies returns all of them, getCookieNamed returns one, addCookie adds one, and deleteCookieNamed or deleteAllCookies remove them. The rule people trip on is that you have to be on a page of that site before you can add its cookie, otherwise the browser rejects it, so I open the home page first, add the cookie, then refresh. The speed trick is logging in once, keeping the session cookie, and adding it in other tests so they start already signed in instead of typing a username and password every time. The login test itself still goes through the real form. I'd also use deleteAllCookies to start a test clean, for example to check what a new visitor sees.”

Code:
driver.get("https://shop.example.com");   // be on the domain first
driver.manage().addCookie(new Cookie("session_id", sessionToken));
driver.navigate().refresh();              // now signed in
Set<Cookie> all = driver.manage().getCookies();
driver.manage().deleteAllCookies();
Red flag to avoid:

Trying to add a cookie before opening any page of the site, or skipping login in the login test itself.

They may ask next:
  • Why might a session cookie you saved stop working in the next run?
  • How would you test that a remember-me checkbox actually keeps the user signed in?
Say it in 60 seconds

Locators 3 questions

Easy Technical round Fresher Practice question

13. What is the difference between an absolute XPath and a relative XPath, and why do testers avoid the absolute kind?

What the interviewer is really testing:
Whether you understand why copying the full path from the browser makes tests break on any small page change.
Answer frame:
Absolute vs Relative
Absolutesingle slash from the html root, every step spelled out.
Relativedouble slash, starts anywhere, anchored on a stable attribute or text.

Why avoid absolute: one new div anywhere above the element breaks it.

Sample spoken answer:

“An absolute XPath starts with a single slash at the root of the page and lists every step down to the element, like /html/body/div[2]/form/div[1]/input. A relative XPath starts with a double slash, which means search anywhere, and points at the element by something that describes it, like //input[@name='email']. I avoid absolute paths because they depend on the whole page layout. If a developer adds a banner or wraps the form in one more div, every index shifts and the locator breaks, even though the email box didn't change at all. A relative XPath on a meaningful attribute survives that. When I started, I copied full XPaths from the browser tools and half my tests broke after one design change, which is how I learned this.”

Code:
Absolute: /html/body/div[2]/form/div[1]/input
Relative: //input[@name='email']
Relative: //form[@id='signup']//input[@type='email']
Red flag to avoid:

Saying absolute XPath is better because it is more exact.

They may ask next:
  • What does a single slash mean in the middle of a relative XPath, compared to a double slash?
  • How do you test an XPath in the browser before putting it in your code?
Say it in 60 seconds
Medium Coding round Fresher Practice question

14. Write XPaths for a button whose text is exactly Sign in, a link whose text contains Forgot, and an input whose id starts with user_.

What the interviewer is really testing:
Whether you can write XPath functions by hand on a whiteboard, not just copy locators from the browser.
Answer frame:

Exact text: text()='...' or normalize-space()='...' to ignore extra spaces.

Partial text: contains(text(),'...').

Prefix: starts-with(@id,'...') for ids with a changing tail.

Sample spoken answer:

“For the exact button text I'd write //button[text()='Sign in']. If the HTML has spaces or a line break around the words, text() won't match, so I prefer //button[normalize-space()='Sign in'], which trims and squeezes the spaces first. For the link I'd use contains: //a[contains(text(),'Forgot')], so it matches Forgot password or Forgot your password. For the input, starts-with works on attributes: //input[starts-with(@id,'user_')]. One thing to know is that XPath is case sensitive, so contains with forgot in lower case won't match Forgot. I check each one in the browser's developer tools by searching in the Elements panel before using it, to be sure it matches exactly one element.”

Code:
//button[text()='Sign in']
//button[normalize-space()='Sign in']
//a[contains(text(),'Forgot')]
//input[starts-with(@id,'user_')]
Red flag to avoid:

Mixing up the syntax, like putting text() outside the brackets, or not knowing XPath is case sensitive.

They may ask next:
  • Is there an ends-with function you can use in browser XPath?
  • When would contains match more elements than you wanted?
Say it in 60 seconds
Medium Coding round Fresher Practice question

15. The Email input has no id or name, but it sits right after a label that says Email. How would you write an XPath to reach the input?

What the interviewer is really testing:
Whether you know XPath axes, which let you move from an element you can find to one you cannot.
Answer frame:

Anchor: find the label by its text.

Move: following-sibling:: if they share a parent, following:: with [1] if not.

Other axes: parent::, ancestor::, preceding-sibling:: for other directions.

Sample spoken answer:

“I'd anchor on the label, since its text is stable, and then move to the input with an axis. If the label and input share the same parent, I'd write //label[normalize-space()='Email']/following-sibling::input. If the input is wrapped in its own div, the sibling axis won't reach it, so I'd use following:: and take the first match, //label[normalize-space()='Email']/following::input[1]. Axes let you walk in any direction: parent to go up one level, ancestor to go up several, preceding-sibling to go backwards. I'd also check if the label has a for attribute, because then the input usually has a matching id and I could use a much simpler locator. I used this in my internship because the forms were generated and had no ids at all.”

Code:
//label[normalize-space()='Email']/following-sibling::input
//label[normalize-space()='Email']/following::input[1]
//input[@type='email']/parent::div
//span[text()='Error']/ancestor::form
Red flag to avoid:

Falling back to an absolute XPath with indexes because the input has no attributes.

They may ask next:
  • What is the difference between following:: and following-sibling::?
  • Can CSS selectors move up to a parent the way XPath can?
Say it in 60 seconds

Waits and Exceptions 2 questions

Easy Technical round Fresher Practice question

16. Your script works when you add Thread.sleep(5000) before a click. Why is that a bad fix, and what would you write instead?

What the interviewer is really testing:
Whether you understand why fixed sleeps make suites slow and still flaky, and can write an explicit wait.
Answer frame:

Why it worked: the element needed time to appear or become clickable.

Why it is bad: it always waits the full time, and it is still too short on a slow day.

Better: WebDriverWait until the exact condition you need.

Sample spoken answer:

“The sleep worked because the element wasn't ready yet, maybe the page was still loading data. But Thread.sleep always waits the full five seconds, even when the button was ready after half a second, so across a hundred steps the suite gets very slow. And on a slow test server five seconds might not be enough, so the test still fails sometimes. Instead I use an explicit wait: a WebDriverWait with a timeout, and ExpectedConditions.elementToBeClickable for that button. It checks again and again and moves on as soon as the button is ready, and only fails if it's still not ready after the full timeout. So it's both faster and more reliable. In my project, replacing sleeps with waits cut the run time roughly in half.”

Code:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement pay = wait.until(ExpectedConditions.elementToBeClickable(By.id("pay")));
pay.click();
Red flag to avoid:

Defending Thread.sleep as fine because it makes the test pass.

They may ask next:
  • What does the wait return if the element never becomes clickable?
  • Which ExpectedConditions would you use to wait for a loading spinner to go away?
Say it in 60 seconds
Medium Technical round Fresher Practice question

17. Name three Selenium exceptions you ran into while learning or in your project, and what caused each one.

What the interviewer is really testing:
Whether you have actually written and debugged Selenium code, and can read an exception name and guess the cause.
Answer frame:

NoSuchElementException: the locator matched nothing, or you looked too early or in the wrong frame.

TimeoutException: an explicit wait ran out before the condition came true.

ElementNotInteractableException: the element exists but is hidden or cannot take input.

Sample spoken answer:

“The first one everyone meets is NoSuchElementException. findElement throws it when the locator matches nothing, and for me the cause was usually a typo in the locator, looking before the page loaded, or the element being inside an iframe. The second is TimeoutException, which comes from an explicit wait when the condition still isn't true after the timeout, so it tells me the page never reached the state I expected. The third is ElementNotInteractableException: the element is in the page, but it's hidden or covered, so Selenium can't type into it. I got that once because the page had two email fields, one hidden for mobile, and my locator picked the hidden one. I also saw NoAlertPresentException when I tried to switch to an alert that hadn't opened yet.”

Red flag to avoid:

Only being able to name exceptions without saying what caused them, or catching every exception and ignoring it.

They may ask next:
  • How would you tell whether a NoSuchElementException is a timing problem or a wrong locator?
  • Which class do all these exceptions extend?
Say it in 60 seconds

TestNG 3 questions

Medium Technical round Fresher Practice question

18. What is the difference between a hard assert and a soft assert in TestNG, and when would you use a soft assert?

What the interviewer is really testing:
Whether you know how TestNG reports failures, and the classic mistake of forgetting assertAll.
Answer frame:
Hard assert vs Soft assert
Hard assertAssert class, stops the test at the first failure.
Soft assertSoftAssert object, collects failures and keeps going.

The catch: call assertAll() at the end, or failures are never reported.

Sample spoken answer:

“A hard assert, from the Assert class, stops the test the moment a check fails, and the rest of the method doesn't run. That's right when later steps depend on it, like if login fails there's no point checking the dashboard. A soft assert uses a SoftAssert object: each failed check is recorded and the test carries on, so in one run I can see every wrong field on a profile page instead of fixing them one at a time. The important part is calling assertAll at the end. If I forget it, the test passes even with failures, because the collected failures are never thrown. I also create a new SoftAssert inside each test, because sharing one across tests mixes their failures together.”

Code:
SoftAssert soft = new SoftAssert();
soft.assertEquals(nameField.getDomProperty("value"), "Asha");
soft.assertEquals(emailField.getDomProperty("value"), "asha@example.com");
soft.assertTrue(saveButton.isEnabled(), "Save should be enabled");
soft.assertAll(); // throws once, listing every failure above
Red flag to avoid:

Not knowing about assertAll, or saying soft asserts are always better.

They may ask next:
  • Where would you not use a soft assert?
  • What does the third argument in assertEquals or the second in assertTrue do?
Say it in 60 seconds
Medium Technical round Fresher Practice question

19. In TestNG, in what order do test methods run by default? How do you force an order, make one test depend on another, or skip one for now?

What the interviewer is really testing:
Whether you know the common attributes of the @Test annotation and what happens when a test it depends on fails.
Answer frame:

Default: methods in a class run in alphabetical order of their names.

Order: priority, lowest number first.

Depend and skip: dependsOnMethods skips the test if the first one fails; enabled = false turns it off.

Sample spoken answer:

“By default TestNG doesn't run methods in the order I wrote them; within a class it runs them in alphabetical order of the method names. To force an order I use the priority attribute, and the lowest number runs first; tests without one get priority zero. If one test really needs another to pass first, like adding to cart needs login, I use dependsOnMethods. Then if login fails, TestNG marks the cart test as skipped instead of failed, which makes the report clearer about the real cause. To turn off a test for now without deleting it, I set enabled to false. I try not to chain too many tests, though, because one failure then skips a lot of them.”

Code:
@Test(priority = 1)
public void login() { }

@Test(priority = 2, dependsOnMethods = "login")
public void addToCart() { }

@Test(enabled = false)
public void applyCoupon() { }
Red flag to avoid:

Assuming TestNG runs methods top to bottom in the order they appear in the file.

They may ask next:
  • What is the difference between dependsOnMethods and dependsOnGroups?
  • Why is it better for each test to log in on its own instead of depending on a login test?
Say it in 60 seconds
Easy Technical round Fresher Practice question

20. What is the testng.xml file for, and what did you put in it in your project?

What the interviewer is really testing:
Whether you have run a suite from a file rather than just clicking run on one class, and know what the file controls.
Answer frame:

Purpose: defines a suite, which classes and tests to run.

Common pieces: suite, test, classes, groups to include or exclude, parameters.

How it runs: from the IDE or through Maven.

Sample spoken answer:

“testng.xml describes a test suite: which test classes to run and how. The top tag is suite, inside it one or more test blocks, and inside those the list of classes. In my project I used it for three things. First, to list the classes for the regression run. Second, to pick groups, so I could run only the tests marked smoke before a demo. Third, to pass a parameter for the browser name, which my setup method read with the @Parameters annotation, so the same tests could run on Chrome or Firefox without changing code. I ran it from the IDE while writing tests, and through Maven with the surefire plugin pointing at the file so it could run from the command line too.”

Code:
<suite name="Smoke">
  <test name="Chrome run">
    <parameter name="browser" value="chrome"/>
    <groups><run><include name="smoke"/></run></groups>
    <classes>
      <class name="tests.LoginTest"/>
      <class name="tests.CartTest"/>
    </classes>
  </test>
</suite>
Red flag to avoid:

Never having seen the file and only ever running single classes from the IDE.

They may ask next:
  • How do you run only one method from a class through testng.xml?
  • What happens if a parameter named in @Parameters is missing from the file?
Say it in 60 seconds

Projects 4 questions

Medium Behavioral round Fresher Practice question

21. Walk me through the automation project on your resume: what app you tested, what you automated, and how your code was organised.

What the interviewer is really testing:
Whether you really built what your resume says, and can explain your own structure and choices in plain words.
Answer frame:

Context: the app, the team size, your part.

What you automated: the flows and roughly how many tests.

Structure and lesson: folders, page classes, TestNG, and one thing you would do differently.

Sample spoken answer:

“In my final-year project I automated tests for a small online bookstore that our team of four built. I owned the testing side. I wrote about twenty-five tests covering sign up, login, search, the cart and checkout with a dummy payment. I used Java, Selenium WebDriver and TestNG, with Maven for dependencies. I kept one class per page, with its locators and actions, so the tests read like steps: log in, search, add to cart. Test data like usernames sat in a properties file, and I took a screenshot whenever a test failed. The tests caught two real bugs, including the cart total not updating after removing an item. If I did it again, I'd use explicit waits from day one, because I spent a week removing sleeps later.”

Red flag to avoid:

Listing tools with no detail on what you personally wrote, or being unable to describe your own folder structure.

They may ask next:
  • Which test in that project broke most often, and why?
  • How did one of your page classes look, and what did it hold?
Say it in 60 seconds
Medium Behavioral round Fresher Practice question

22. Tell me about a time in a college or internship project when one of your tests failed and you had to work out whether the app or your script was wrong.

What the interviewer is really testing:
Whether you debug calmly and prove the cause before blaming the developers or quietly changing the test.
Answer frame:

Situation: what failed and the error you saw.

Checks: repeat it by hand, look at the screenshot, test the locator in the browser.

Result: what it turned out to be and what you did about it.

Sample spoken answer:

“During my internship a checkout test started failing with a TimeoutException waiting for the order confirmation. My first thought was that my wait was too short, but instead of just raising it I did the same steps by hand. The confirmation never appeared manually either; the page showed a spinner forever when the cart had a discounted item. So I checked the failure screenshot, saw the same spinner, and tried a cart with no discount, which worked. That told me it was the app, not my script. I wrote a bug report with the exact steps, the test data and the screenshot, and the developer found a crash in the discount calculation. I learned to reproduce by hand before touching a failing test.”

Red flag to avoid:

Increasing timeouts or deleting the check until the test goes green, without finding out why it failed.

They may ask next:
  • What would you have done if it worked by hand but still failed in the script?
  • How did you write the bug report so the developer could reproduce it?
Say it in 60 seconds
Medium Situational round Fresher Practice question

23. Your Selenium tests pass on your laptop, but your teammate pulls the same code and every test fails at startup. What do you check?

What the interviewer is really testing:
Whether you can debug environment problems and know the usual culprits: browser and driver versions, hard-coded paths and local settings.
Answer frame:

Read the error: the first lines usually name the problem.

Versions and paths: browser vs driver version, hard-coded driver or file paths.

Settings: URLs, test data, screen size and Java version, then fix it for everyone.

Sample spoken answer:

“First I'd read the actual error on their machine, because failing at startup usually means the browser never opened. The most common cause is a driver that doesn't match their browser version, or a hard-coded path like my own C drive folder for chromedriver, which doesn't exist on their laptop. On recent Selenium 4 I'd remove the manual driver path and let Selenium manage it. Next I'd look for other things tied to my machine: a base URL pointing at my localhost, test data files with my folder path, or a different Java version. If tests fail later rather than at startup, I'd check screen size, since a smaller window can hide elements. Then I'd fix it in the code, like moving settings into a config file, so it doesn't happen to the next person.”

Red flag to avoid:

Telling the teammate to copy your exact setup instead of removing what ties the code to your machine.

They may ask next:
  • How would you make the browser window the same size on every machine?
  • Where would you keep settings like the base URL and browser name?
Say it in 60 seconds
Medium Situational round Fresher Practice question

24. On your first week as an intern, you are asked to automate the login page. Which tests would you write first, and what would you ask before starting?

What the interviewer is really testing:
Whether you think like a tester, choosing the most valuable cases first and spotting blockers like captcha or OTP early.
Answer frame:

Ask first: test accounts, which environment, and whether there is a captcha or OTP.

First tests: valid login, wrong password, empty fields.

Next: locked account, logout, forgot password link, password field masked.

Sample spoken answer:

“Before writing code I'd ask three things: which environment I should test on, whether there are test accounts I'm allowed to use, and whether there's a captcha or an OTP, because I can't automate those and would need a test bypass. Then I'd start with the cases that matter most. A valid login lands on the dashboard. A wrong password shows the right error and doesn't log in. Empty username or password shows a validation message. After those, I'd add a locked or disabled account, logout, the forgot password link opening the right page, and checking that the password field hides what I type. I'd keep test data out of the code, and show my lead the first three tests before writing the rest, so I learn their standards early.”

Red flag to avoid:

Starting to code without asking about test accounts or captcha, or only testing the happy path.

They may ask next:
  • Which of these would you leave as a manual check, and why?
  • How would you check the password field hides the characters?
Say it in 60 seconds
Were you asked something else? Share it A person checks every question before it goes on the site. No name is shown.
For the call itself

You practiced these. On the real call, ClapAssist helps with the rest.

ClapAssist is an AI interview assistant for Mac and Windows. It listens to the interview on your computer and shows you what to say, in short lines you can read while you talk. Your live interview audio and screen are never stored. Your resume and notes are saved to your account so the app fills them in on any computer. It stays out of screen share on every plan, including Free; only you can see it.

Download with 10 free minutes
Mac and Windows · Stays out of screen share · No card