Skip to content

Swiggy Automation Testing Interview Questions & Answers

Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.

Solved for SwiggyStart practicing
3 QUESTIONS FREESign up or log in 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

How do you handle environment-specific configuration?

SwiggyMedium
Save to ▾
Show answer
Keep URLs and credentials in per-environment config files or variables, choose with a command-line parameter and never hard-code secrets.
02

What are the different types of waits in Selenium?

SwiggyMedium
Save to ▾
Show answer
Implicit, explicit (WebDriverWait with ExpectedConditions) and fluent waits; avoid mixing implicit and explicit waits and never rely on Thread.sleep.
03

How do you handle dropdowns in Selenium?

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

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
05

How would you design a CI pipeline for nightly regression?

Save to ▾
Show answer
Schedule the job, spin up environments or containers, run suites in parallel, store reports and screenshots, notify failures on Slack or email and track trends.
06

Where do you use OOP concepts in your framework?

SwiggyMedium
Save to ▾
Show answer
Encapsulation: private locators with public page methods. Inheritance: pages extend a BasePage. Polymorphism: the WebDriver interface for different browsers. Abstraction: utility layers hiding Selenium details.
07

What are the advantages of version control for test code?

SwiggyMedium
Save to ▾
Show answer
Git tracks changes, enables code review, branching and rollback and lets teams collaborate on the framework safely.
08

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

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

How do you verify that an element is displayed, enabled or selected?

SwiggyMedium
Save to ▾
Show answer
Use isDisplayed(), isEnabled() and isSelected() on the WebElement before interacting or asserting.
10

What is data-driven testing?

SwiggyMedium
Save to ▾
Show answer
Running the same test logic with multiple data sets from Excel, CSV, JSON or a database, so coverage increases without duplicating code.
11

How do you make WebDriver thread-safe for parallel runs?

SwiggyMedium
Save to ▾
Show answer
Store each driver in a ThreadLocal so every thread gets its own instance and tests do not interfere.
12

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.
13

What is Selenium and what are its components?

Save to ▾
Show answer
An open-source suite for browser automation: WebDriver, IDE, Grid and the older RC. WebDriver controls browsers through their native drivers.
14

How do you handle dynamic elements whose ids change?

SwiggyMedium
Save to ▾
Show answer
Use CSS or XPath with contains(), starts-with() or stable attributes, relative axes, or data-test attributes agreed with developers.
15

What is the difference between driver.close() and driver.quit()?

SwiggyMedium
Save to ▾
Show answer
close() closes the current window; quit() closes all windows and ends the driver session.
16

What is Docker and how does it help tests?

SwiggyMedium
Save to ▾
Show answer
Docker packages tools in containers so tests run identically everywhere; Selenium Grid and browsers can be started quickly in containers.
17

What are Java collections and which ones do testers use most?

SwiggyMedium
Save to ▾
Show answer
ArrayList and LinkedList for lists, HashSet for unique values, HashMap for key-value test data, and Iterator for traversing them, for example collecting web elements in a list.
18

How do you run tests in parallel?

SwiggyMedium
Save to ▾
Show answer
Use TestNG parallel="methods | classes | tests" with thread-count, keep WebDriver in a ThreadLocal, and use Selenium Grid or a cloud grid for multiple browsers.
19

What is the execution order of TestNG annotations?

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

What are relative locators in Selenium 4?

SwiggyMedium
Save to ▾
Show answer
Locators such as above, below, toLeftOf and near that find elements by their position relative to another element.
21

What does dependsOnMethods do?

SwiggyMedium
Save to ▾
Show answer
It makes a test run only after specified tests pass, otherwise it is skipped. Use sparingly as it creates coupled tests.
22

How do you validate a JSON response in REST Assured?

SwiggyMedium
Save to ▾
Show answer
Use then().statusCode(200).body("data.id", equalTo(5)), or extract() the response and assert fields with JsonPath.
23

How do you manage test data in a framework?

SwiggyMedium
Save to ▾
Show answer
Use external files or APIs and database setup scripts, generate unique data per run, and clean up afterwards so tests stay independent.
24

What is the difference between hard and soft assertions?

SwiggyMedium
Save to ▾
Show answer
Hard assert stops the test at the first failure; SoftAssert collects failures and reports them together when assertAll() is called.
25

Write an XPath for a button with the text "Login".

Save to ▾
Show answer
//button[normalize-space()='Login'] //button[contains(text(),'Login')]
26

What is the Page Object Model?

Save to ▾
Show answer
A design pattern where each page is a class holding its locators and actions, so tests stay readable and a locator change is fixed in one place.
27

What new features came with Selenium 4?

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

How would you automate a login flow with multiple user roles?

Save to ▾
Show answer
Keep credentials in external data, parameterise the test with a data provider, reuse a login method in a page class, and clear sessions between roles.
29

How does HashMap work internally?

SwiggyMedium
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.
30

How do you handle iframes?

SwiggyMedium
Save to ▾
Show answer
switchTo().frame(index, name or element) enters the frame, and switchTo().defaultContent() returns to the main page.
31

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.
32

What is a constructor and can it be overloaded?

SwiggyMedium
Save to ▾
Show answer
A special method that initialises an object. It can be overloaded with different parameters, and testers use it to pass the WebDriver into page classes.
33

How do you reduce flakiness in a CI pipeline?

Save to ▾
Show answer
Stabilise waits and data, isolate tests, use retries cautiously, quarantine unstable tests, run in consistent containers and track flaky rates.
34

Difference between an abstract class and an interface?

Save to ▾
Show answer
An abstract class can hold state and concrete methods; an interface defines a contract (with default methods since Java 8). A class extends one abstract class but can implement many interfaces.
35

What is contract testing?

SwiggyMedium
Save to ▾
Show answer
Verifying that a provider and consumer agree on request and response formats, using tools like Pact, to catch breaking changes early.
36

findElement vs findElements?

Save to ▾
Show answer
findElement returns the first match and throws NoSuchElementException if nothing is found. findElements returns a List (empty if nothing is found) — handy to check whether an element exists.
37

What is the difference between an array and an ArrayList?

SwiggyMedium
Save to ▾
Show answer
Arrays have a fixed size and can hold primitives; ArrayList grows dynamically, holds objects and offers helper methods.
38

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.
39

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.
40

How do you handle a dropdown that is not a <select> tag?

SwiggyMedium
Save to ▾
Show answer
Click to open the dropdown, then locate the option by its text, e.g. //li[text()='India'], and click it. Add an explicit wait for the animation.
41

Write a GET test in REST Assured.

SwiggyMedium
Save to ▾
Show answer
given().baseUri(url) .when().get("/users/1") .then().statusCode(200).body("id", equalTo(1));
42

How do you upload a file with Selenium?

SwiggyMedium
Save to ▾
Show answer
If the element is <input type="file">, use element.sendKeys("C:/path/file.pdf"). Use the Robot class or AutoIt only as a last resort for OS dialogs.
43

What is a Jenkins pipeline?

SwiggyMedium
Save to ▾
Show answer
A scripted or declarative Jenkinsfile that defines stages such as build, test and deploy as code stored with the project.
44

Difference between ArrayList and LinkedList?

SwiggyMedium
Save to ▾
Show answer
ArrayList has fast random access and slower inserts in the middle; LinkedList has fast inserts and deletes but slow access by index.
45

How do you pass authentication in an API test?

SwiggyMedium
Save to ▾
Show answer
Use headers such as Bearer tokens, basic auth, API keys or OAuth flows; fetch a token in a setup step and reuse it.
46

What is CI/CD and why does automation need it?

SwiggyMedium
Save to ▾
Show answer
Continuous Integration builds and tests every commit, and Continuous Delivery ships automatically. Automated tests give fast feedback and gate releases.
47

How do you verify response time and headers in REST Assured?

SwiggyMedium
Save to ▾
Show answer
Use then().time(lessThan(2000L)) and then().header("Content-Type", containsString("json")) along with body assertions.
48

Tests pass locally but fail on Jenkins. Why?

Save to ▾
Show answer
Headless mode or screen resolution, timing issues, environment data, missing dependencies, browser–driver version mismatch or parallel conflicts. Check logs and failure screenshots and make waits robust.
49

What is an API and what are common HTTP methods?

Save to ▾
Show answer
An interface for systems to talk to each other. GET reads, POST creates, PUT replaces, PATCH updates partially and DELETE removes.
50

What are Java 8 streams and lambdas?

SwiggyMedium
Save to ▾
Show answer
Lambdas are short anonymous functions; streams process collections declaratively with filter, map and collect, for example filtering link text from a list of elements.