Introduction
Are you preparing for a technical interview at CGI? Whether you’re applying for a role in automation testing, Java development, or full stack testing, it’s crucial to review key concepts across Core Java, Selenium WebDriver, frameworks, API testing, and more.
In this blog, we’ve compiled a comprehensive list of CGI Interview Questions & Answers to help you assess your readiness and practice effectively. These questions are frequently asked during CGI’s technical interviews and cover both theoretical and hands-on topics.
Core Java:
- Write a Java program to reverse the words in a sentence.
- Write a Java program to extract only the non-duplicate characters from a string.
- What is the difference between List and Set in Java?
- How is encapsulation implemented in your framework?
Selenium WebDriver:
- Given a web table, how would you write a dynamic XPath to extract the country name without using link text or visible text?
- Provide a code snippet using Explicit Wait (WebDriverWait) in Selenium.
- What are some of the common exceptions you’ve faced in Selenium?
- Describe a real-time Actions class scenario you have automated.
- How do you handle JavaScript alerts using Selenium?
- How do you switch between frames in Selenium?
Framework & Design Patterns:
- Explain the Page Object Model (POM) with examples.
- What type of framework have you developed or worked on? Please explain its components and structure.
- How are interfaces and abstract classes used in your test automation framework?
Cucumber BDD:
- What is the purpose of the Background keyword in Cucumber BDD?
- Explain Hooks in Cucumber. When and why do you use them?
- What is the purpose of Scenario Outline in Cucumber?
- What are Cucumber plugins and which ones have you used?
- What is the role of DryRun in Cucumber and when do you use it?
Git & Version Control:
- Write the code to commit changes using Git.
- Explain how you handle merge conflicts in Git.
API Testing (REST Assured / Postman):
- What is the difference between query parameters and path parameters in REST APIs?
- What are the commonly used HTTP methods in RESTful services?
- What is the difference between POST and PUT methods in REST API?
- What types of authentication mechanisms have you used in API testing?
- What are some error codes you’ve encountered during API testing and what do they signify?
Testing Concepts:
- What is regression coverage and how do you ensure it?
- What is included in a Test Plan? List its key components.
- How do you estimate efforts in software testing?
GCI INTERVIEW QUESTIONS WITH ANSWER
1. Write a Java program to reverse the words in a sentence.
public class ReverseWords {
public static void main(String[] args) {
String input = “Today is Tuesday”;
String[] words = input.split(” “);
StringBuilder reversed = new StringBuilder();
for (int i = words.length – 1; i >= 0; i–) {
reversed.append(words[i]).append(” “);
}
System.out.println(reversed.toString().trim());
}
}
2. Write a Java program to extract only the non-duplicate characters from a string.
public class NonDuplicateChars {
public static void main(String[] args) {
String input = “Today is Tuesday”;
input = input.replaceAll(” “, “”).toLowerCase(); // Remove spaces and convert to lowercase
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (input.indexOf(c) == input.lastIndexOf(c)) {
System.out.print(c);
}}}}
3. What is the difference between List and Set in Java?
- List is an ordered collection that can contain duplicate elements. It allows you to access elements by index.
- Set is an unordered collection that does not allow duplicates. It ensures that each element is unique.
- List maintains the insertion order. The elements are returned in the same sequence they were added.
- Set generally does not guarantee order (e.g., HashSet). However, specific implementations like LinkedHashSet maintain insertion order, and TreeSet maintains sorted order.
- List allows duplicate values. You can add the same element multiple times.
- Set automatically removes duplicates and only stores unique elements.
- List supports index–based access using methods like get(int index), set(int index, E element), etc.
- Set does not support index–based access because it does not maintain position-based storage.
- List is better suited when you need frequent access to elements using index or when order matters.
- Set is better suited when fast lookup and uniqueness are required.
4. How is encapsulation implemented in your framework?
- Encapsulation is one of the core principles of Object-Oriented Programming, and we’ve implemented it effectively in our automation framework to improve maintainability and thread safety.
- For example, we encapsulate our WebDriver instance using a utility class called DriverManager. Instead of exposing the WebDriver directly, we use a ThreadLocal<WebDriver> variable, which ensures that each test thread gets its own isolated driver instance.
- This is especially useful when running tests in parallel execution, as it avoids issues related to thread conflicts. The WebDriver is declared as private static ThreadLocal<WebDriver> driver, and access is only provided through public getter and setter methods.
- This approach follows encapsulation principles by hiding the driver implementation and exposing only controlled methods to interact with it, improving both test reliability and code reusability.
5. Given a web table, how would you write a dynamic XPath to extract the country name without using link text or visible text?
To extract the country name dynamically from a web table without relying on link text or visible text, I prefer using relative XPath that navigates through the structure of the table based on the DOM hierarchy, such as rows and cells.
If the column position changes, I use a logic to identify the index of the header Country, then use that dynamic index to build the XPath for the country column cells. This keeps the locator truly dynamic and resistant to UI changes.
6. Provide a code snippet using Explicit Wait (WebDriverWait) in Selenium.
Explicit Wait in Selenium is used when we want to wait for a specific condition to occur before proceeding further in the code. It is implemented using the WebDriverWait class along with ExpectedConditions.
For example, I use Explicit Wait when I need to wait for an element to become clickable or visible before performing an action like click or sendKeys. This helps prevent issues like ElementNotInteractableException or NoSuchElementException during dynamic page loading.
7. What are some of the common exceptions you’ve faced in Selenium?
- NoSuchElementException
- ElementNotInteractableException
- StaleElementReferenceException
- TimeoutException
- ElementClickInterceptedException
- InvalidSelectorException
- WebDriverException
- SessionNotCreatedException
- UnhandledAlertException
- NoAlertPresentException
8. Describe a real-time Actions class scenario you have automated.
In one of the web applications I automated — an internal HR Management System — there was a top navigation menu called “Employees”. When a user hovered the mouse over it, a submenu appeared with options like “Manage Employees” and “Add New Employee”.
The challenge here was that the submenu would only appear on mouse hover, and a regular click() operation wouldn’t work because the submenu elements were not visible in the DOM until the hover action was triggered.
To handle this, I used the Actions class in Selenium. Using Actions.moveToElement(), I simulated the mouse hovering over the “Employees” menu. Once the submenu became visible, I performed another move and click action on “Add New Employee”.
This allowed the automation script to successfully navigate through the menu just like a real user would. It was especially helpful for testing modules where menu items are only visible through hover interactions — something common in admin dashboards, CRMs, and e-commerce sites.
9. How do you handle JavaScript alerts using Selenium?
In Selenium, JavaScript alerts are handled using the Alert interface, which is part of the org.openqa.selenium package. These alerts are pop-up dialogs generated by the browser using JavaScript — such as alert, confirm, or prompt boxes.
To handle them, I first switch the driver’s focus to the alert using driver.switchTo().alert(). Once switched, I can perform operations like:
- accept() – to click OK
- dismiss() – to click Cancel
- getText() – to capture the alert message
- sendKeys() – to input text in prompt alerts
10. How do you switch between frames in Selenium?
In Selenium, we use the switchTo().frame() method to switch the driver’s focus from the main webpage to a frame or iframe. This is necessary because elements inside a frame cannot be accessed directly from the main page — Selenium must switch context first.
Web applications often embed content like ads, forms, or documents inside <iframe> tags. If we try to interact with elements inside a frame without switching to it, Selenium will throw a NoSuchElementException.
11. Explain the Page Object Model (POM) with examples.
Page Object Model (POM) is a design pattern used in Selenium to make test automation more maintainable, readable, and reusable. In one of my projects, we had multiple pages — Login, Dashboard, Orders, and Reports. Each page had its own class. So when UI elements changed on the Login page, I only updated the LoginPage.java file — not all test cases. That made the maintenance much easier.
12. What type of framework have you developed or worked on? Please explain its components and structure.?
I have worked on a Hybrid Framework which combines the benefits of multiple frameworks such as Data-Driven, Keyword-Driven, and Page Object Model (POM). This framework was built using Java, Selenium WebDriver, TestNG, and Apache POI for Excel-based data handling.
Framework Components and Structure:
Base Class:
- A reusable class that contains common setup code like browser launch, URL loading, browser configuration, and teardown logic (using @BeforeMethod and @AfterMethod in TestNG).
Page Classes (POM):
- Each web page has a separate Java class where web elements and related actions are defined. This helps in better modularity and maintainability.
Test Scripts:
- All test cases are written using TestNG. They call methods from the page classes to perform actions and assertions. Test scripts are well-organized by modules or features.
Data Utility (Data-Driven):
- Test data is maintained separately in Excel files. We use Apache POI to read data and pass it dynamically to test methods using DataProvider in TestNG.
Keywords Utility (Keyword-Driven logic):
- In some cases, we use external Excel sheets to define test steps and actions as keywords (e.g., “click”, “type”, “select”). These are mapped to actual methods via a central keyword engine.
Utilities:
- Contains helper classes like:
- Wait utility (explicit waits)
- Screenshot utility
- Excel utility
- File reading (properties/config)
- Logger utility (e.g., Log4j)
Configuration Files:
- We maintain a config.properties file for dynamic values like URLs, browser type, credentials, etc. This makes the framework flexible and environment-independent.
TestNG XML:
- Used to group and run test suites, control execution flow, and enable parallel execution.
Reports:
- We use ExtentReports or Allure Reports to generate rich HTML reports after execution, including screenshots for failed steps.
Maven or Gradle Integration (optional):
We used this hybrid framework to automate the regression suite of a travel booking application. It helped us run tests with multiple sets of input data, cover multiple browsers, and maintain the scripts easily as the application evolved.
13. How are interfaces and abstract classes used in your test automation framework?
In my test automation framework, I use abstract classes and interfaces to make the code more organized, reusable, and scalable by following object-oriented programming principles. We create an abstract class, usually called a Base Class, that contains all the common setup and teardown methods required for every test.
We create an abstract class, usually called a Base Class, that contains all the common setup and teardown methods required for every test.
14. Explain Hooks in Cucumber. When and why do you use them?
Hooks in Cucumber are special methods that run automatically before or after each scenario or step execution.
They allow you to perform setup and teardown tasks without writing repetitive code inside each test scenario.
For example, the @Before hook is used to initialize the test environment, such as launching the browser and navigating to the application URL before the scenario runs.
Similarly, the @After hook is used to clean up after the scenario, like closing the browser, clearing cookies, or capturing screenshots if a test fails.
Hooks improve the maintainability and readability of test code by centralizing common preconditions and postconditions, ensuring each scenario runs in a fresh and controlled environment.
They are essential for avoiding duplication, reducing errors, and making the test automation framework more robust and scalable.
15. What is the purpose of scenario outline in Cucumber?
Scenario Outline in Cucumber is used to run the same scenario multiple times with different sets of input data. It allows you to write a single scenario template with placeholders, and then provide various example values in an Examples table. Each row in the Examples table represents a different test iteration with specific inputs.
This helps avoid duplicating similar scenarios and makes tests more organized and maintainable when validating the same functionality with multiple data sets.
16. What are Cucumber plugins and which ones have you used?
Cucumber plugins are additional tools or extensions that enhance the functionality of your Cucumber test execution. Their main purpose is to help you generate test execution reports in various formats, customize the test output, or integrate Cucumber with other tools and frameworks.
When you run Cucumber tests, these plugins automatically collect information about the tests and produce readable reports or logs that make it easier to analyze the test results.
In one of my projects, we configured Cucumber to use the pretty, html, and json plugins together. The pretty plugin helped during local test development by showing the steps clearly on the console.
The html report was automatically generated after each test run and uploaded to our test management system so that QA managers could review results easily. The json output was fed into an Allure reporting tool that created interactive, rich reports with screenshots and detailed logs.
17. What is the role of DryRun in Cucumber and when do you use it?
DryRun is a special mode in Cucumber that lets you check whether all the steps defined in your feature files have corresponding step definitions implemented in your code without actually running the tests.
When DryRun is enabled, Cucumber scans the feature files and verifies the mapping with step definitions. If any steps are missing implementations, it lists them so you can quickly identify and create the missing code.
18. Write the code to commit changes using Git.
git add .
git commit -m “Your commit message here“
git add . — Stages all modified and new files in the current directory for commit.git commit -m “Your commit message here” — Commits the staged changes with a descriptive message inside quotes.
git add filename1 filename2
git commit -m “Your commit message“
19. Explain how you handle merge conflicts in Git.
When a merge conflict occurs in Git, it means that changes in two branches affect the same part of a file and Git cannot automatically decide which version to keep.
To handle this, I first open the conflicted files and look for conflict markers (<<<<<<< , = = = = = = =, >>>>>>>) that show the conflicting changes. Then, I carefully review both versions, decide which changes to keep, modify the code accordingly, and remove the conflict markers.
After resolving all conflicts, I stage the fixed files using git add and complete the merge by committing the changes with git commit. Finally, I verify that the merged code works correctly before pushing it to the remote repository. This process ensures that no important code is lost and the project remains stable.
20. What is the difference between query parameters and path parameters in REST APIs?
Path parameters are part of the URL path itself and are used to identify a specific resource. They are mandatory and appear as placeholders within the URL, for example: /users/{userId} where {userId} is a path parameter specifying which user to access.
Query parameters, on the other hand, are optional key-value pairs appended to the end of the URL after a question mark (?). They are used to filter, sort, or customize the response, such as /users?age=25&sort=asc, where age and sort are query parameters controlling which users to fetch and how to order them.
21. What are the commonly used HTTP methods in RESTful services?
The commonly used HTTP methods in RESTful services are:
GET — Retrieves data or resources from the server without modifying anything. For example, fetching user details.
POST — Sends data to the server to create a new resource. For example, creating a new user.
PUT — Updates an existing resource completely or creates it if it doesn’t exist. For example, updating user information.
PATCH — Partially updates an existing resource with only the changes. For example, updating only the user’s email.
DELETE — Removes a resource from the server. For example, deleting a user.
OPTIONS — Returns the HTTP methods supported by the server for a specific resource, often used for CORS preflight requests.
22. What is the difference between POST and PUT methods in REST API?
The POST method is used to create a new resource on the server, and each time you send a POST request, it may create a new entry—even if the data is the same—because it’s not idempotent.
The PUT method is used to update an existing resource or create it if it doesn’t already exist. It is idempotent, meaning sending the same request multiple times will always result in the same outcome. With POST, the server generates the resource ID, while with PUT, the client specifies the ID in the URL.
23. What types of authentication mechanisms have you used in API testing?
In API testing, I have used various authentication mechanisms to access secured endpoints. The most common one is Basic Authentication, where the username and password are encoded in Base64 and sent in the request header.
I’ve also worked with Bearer Token Authentication, where an access token is passed in the header to authorize requests, commonly used in OAuth-based systems. In addition, I’ve handled API Key Authentication, where a unique key is included either in the header or as a query parameter. These mechanisms ensure that only authorized users or systems can access the APIs during testing.
24. What are some error codes you’ve encountered during API testing and what do they signify?
- 400 Bad Request – This means the server could not understand the request due to invalid syntax, like sending malformed JSON or missing required fields.
- 401 Unauthorized – This indicates that authentication has failed or the user is not logged in; usually happens when the token or credentials are missing or incorrect.
- 403 Forbidden – The request is valid, but the user does not have permission to access the resource, even if authenticated.
- 404 Not Found – This means the requested resource does not exist on the server, such as a wrong endpoint or ID.
- 405 Method Not Allowed – The HTTP method (like POST, PUT) is not allowed on that particular endpoint.
- 500 Internal Server Error – This is a generic server-side error, indicating that something went wrong on the server while processing the request.
- 502 Bad Gateway – This happens when the server acting as a gateway receives an invalid response from the upstream server.
- 503 Service Unavailable – The server is temporarily unavailable, possibly due to maintenance or overload.
25. What is regression coverage and how do you ensure it?
Regression coverage means ensuring that all previously working features of an application continue to work after code changes. To ensure it, I maintain a comprehensive suite of regression test cases that cover critical functionalities, and I run these tests regularly, especially after each deployment or code change.
I also use test automation to speed up the regression cycle, traceability matrices to map test cases to requirements, and code coverage tools to identify untested areas. This helps catch unexpected issues early and ensures application stability.
26. What is included in a Test Plan? List its key components?
A Test Plan is a detailed document that outlines the strategy, objectives, scope, schedule, resources, and activities for testing a software application. Its key components typically include:
- Test Plan ID – A unique identifier for the test plan.
- Introduction – Overview of the project and objectives of the test plan.
- Test Items – The features or modules to be tested.
- Scope (In-scope & Out-of-scope) – What will and will not be tested.
- Test Strategy – The approach to testing (manual, automation, levels of testing, etc.).
- Test Environment – Details of the hardware, software, tools, and setup needed.
- Test Deliverables – Documents and reports to be produced (e.g., test cases, test data, test summary report).
- Schedule – Timeline for each testing activity.
- Roles and Responsibilities – Who will perform which testing tasks.
- Entry and Exit Criteria – Conditions to start and stop testing.
- Risk and Mitigation – Possible risks and how to handle them.
- Approvals – Sign-off from stakeholders.
These components ensure structured and effective testing throughout the software development lifecycle.
27. How do you estimate efforts in software testing?
Effort estimation in software testing involves predicting the time and resources needed to complete testing activities. I typically estimate efforts based on the complexity of the application, the number and size of test cases, the types of testing required (like functional, regression, integration), and the test environment setup time. I also consider team experience, past project data, and include buffer time for unexpected issues. Estimation techniques like Work Breakdown Structure (WBS), Three-Point Estimation, or Test Case Point method can be used to break the work into smaller tasks and assign realistic time frames. This helps in better planning, resource allocation, and on-time delivery.
Conclusion
Preparing for CGI interviews requires a strong grasp of both technical fundamentals and real-world project experience. The questions shared above are designed to reflect what CGI typically looks for in candidates across various domains like Java, automation frameworks, API testing, and version control. Focus on writing clean, maintainable code, understanding design patterns, and demonstrating clarity in your test strategy. With consistent practice and clear communication, you’ll be well-positioned to succeed in your CGI interview.
We Also Provide Training In:
- Advanced Selenium Training
- Playwright Training
- Gen AI Training
- AWS Training
- REST API Training
- Full Stack Training
- Appium Training
- DevOps Training
- JMeter Performance Training
Author’s Bio:
As CEO of TestLeaf, I’m dedicated to transforming software testing by empowering individuals with real-world skills and advanced technology. With 24+ years in software engineering, I lead our mission to shape local talent into global software professionals. Join us in redefining the future of test engineering and making a lasting impact in the tech world.
Babu Manickam
CEO – Testleaf