Introduction
Preparing for an interview can feel like navigating through a maze of concepts, tools, and best practices. With the rapidly evolving landscape of technology, interviewers are keen on assessing not just technical expertise but also problem-solving abilities and hands-on experience.
In this blog, we’ve compiled a comprehensive list of interview questions frequently asked in Capgemini interviews. These questions are tailored for both beginners and experienced professionals, covering a variety of topics ranging from foundational concepts to advanced-level problem-solving. Whether you’re just starting your career or seeking to level up, this guide will serve as your one-stop resource to prepare effectively for Capgemini’s hiring process. These questions are designed to help you prepare for the three critical rounds of the Capgemini interview process which was asked recently. Whether you’re a beginner or an experienced professional, these questions will ensure you’re fully equipped to face each round with confidence.
Round -1
1.Find elements and find element difference.
In Selenium, findElement and findElements are methods used to locate web elements on a page. While findElement retrieves a single element, findElements fetches multiple matching elements, each serving unique purposes in automation.
Let see the difference in details:
– findElement returns a single WebElement, while findElements returns a list of WebElements.
– findElement throws a NoSuchElementException if no element is found, but findElements returns an empty list.
– findElement stops searching after finding the first matching element, whereas findElements searches for all matching elements.
– findElement is used for locating a unique element, while findElements is used for locating multiple elements.
– findElement requires exception handling for missing elements, whereas findElements avoids exceptions by returning an empty list.
– findElement is faster when targeting a single element, while findElements may take more time as it processes all matches.
– findElement is ideal for interacting with specific elements like a login button, while findElements is used for tasks like validating all links on a page.
– findElement cannot iterate over elements, but findElements allows iteration using loops.
2.Explain TestNG annotations.
TestNG annotations are a crucial aspect of the TestNG framework, enabling testers to define test case behavior, execution order, and lifecycle. In this document, we will delve into the uses, common annotations, and implementation of TestNG annotations.
Uses of TestNG Annotations
TestNG annotations serve several purposes:
1. Test Setup and Teardown: Manage test setup and teardown, ensuring a clean test environment.
2. Test Execution Flow and Dependencies: Control test execution flow and dependencies, allowing for efficient test execution.
3. Parameterization and Grouping: Enable parameterization and grouping of tests, making test maintenance and execution more efficient.
Common TestNG Annotations
Here are some commonly used TestNG annotations:
1. @BeforeSuite and @AfterSuite: Execute code before or after the test suite runs.
2. @BeforeTest and @AfterTest: Execute code before or after a set of test methods defined in the TestNG XML.
3. @BeforeClass and @AfterClass: Execute code before or after all methods in a specific class.
4. @BeforeMethod and @AfterMethod: Execute code before or after each test method.
5. @Test: Define a test case.
6. @DataProvider: Provide data for parameterized tests.
7. @Parameters: Pass parameters from the TestNG XML file.
Implementation of TestNG Annotations
TestNG annotations are implemented in various ways:
1. Automation Frameworks: Used for setup/teardown in automation frameworks (@BeforeMethod, @AfterMethod).
2. Parameterized Testing: Used for parameterized testing (@DataProvider, @Parameters).
3. Grouping and Executing Test Sets: Used for grouping and executing specific test sets.
By leveraging TestNG annotations, testers can create efficient, maintainable, and scalable test suites that meet the demands of modern software testing.
3.How do you perform Parallel testing?
To improve test execution speed, utilize system resources efficiently, and run tests on multiple browsers or environments simultaneously, TestNG parallel testing is used.
Cross-browser testing to ensure compatibility across different browsers, running large test suites faster in CI/CD pipelines, and validating applications across multiple environments in parallel are some scenarios where TestNG parallel testing is applied.
To perform parallel testing,in the TestNG XML file, add the parallel attribute to the <suite> tag and set its value to one of the following:
– methods: Run test methods in parallel.
– classes: Run test classes in parallel.
– tests: Run test cases in parallel.
Syntax to configure parallel testing using TestNG:
– Parallel by Methods: <suite name=”Suite” parallel=”methods” thread-count=”4″>
– Parallel by Classes: <suite name=”Suite” parallel=”classes” thread-count=”4″>
– Parallel by Tests: <suite name=”Suite” parallel=”tests” thread-count=”4″>
The thread-count attribute specifies the number of threads to run in parallel.
4.How to pass parameter in TestNG and priority how to use.
In TestNG, there are two primary ways to pass parameters to test methods: using the @Parameters annotation and the @DataProvider annotation.
Using @Parameters Annotation:
Parameters are defined in the testng.xml file.
These parameters are referenced in the test method using the @Parameters annotation.
This method is useful for passing fixed values to test methods.
Using @DataProvider Annotation:
A data provider method is created, which returns a set of data.
The @DataProvider annotation is used to link this data provider to the test method.
This approach is ideal for running the same test multiple times with different data sets.
Setting Priorities:
Priorities in TestNG are set using the priority attribute of the @Test annotation.
Test methods with lower priority numbers are executed first.
If multiple test methods have the same priority, their execution order is not guaranteed.
5.How to upload file?
Uploading a file using Selenium can be achieved through the following methods:
Using send_keys() method
You can use the send_keys() method to upload a file by sending the file path to the file input element.
WebElement uploadElement = driver.findElement(By.xpath(“//input[@type=’file’]”));
// Upload the file by sending the file path
uploadElement.sendKeys(“C:\\path\\to\\your\\file.txt”);
System.out.println(“File uploaded successfully!”);
6.Other way to upload file is robot, why it is not preferred.
Using the `Robot` class in Java Selenium for file uploads is often not preferred due to:
1. Platform Dependence: Varies across different operating systems, leading to inconsistent results.
2. Timing Issues: Sensitive to the application’s responsiveness, causing potential failures.
3. Lack of Control: Less control and feedback compared to WebDriver’s direct interactions.
4. Test Stability: Prone to instability and failures due to reliance on exact positioning.
5. Maintenance Complexity: Increased maintenance due to hardcoded coordinates and actions.
WebDriver provides a more reliable and maintainable approach by interacting directly with web elements.
7.Expalin Window Handling?
Window handling is necessary when a web application opens new browser windows or tabs for certain actions, such as pop-ups, advertisements, or separate screens for different functionalities.
It is used in scenarios where interactions with multiple windows or tabs are required to complete a test case.
It ensures that automated tests can seamlessly interact with and verify the functionality across multiple windows, improving test coverage and reliability.
In Selenium Java, window handling is used to manage multiple browser windows or tabs during a test. The basic syntax involves:
To get the main window handle:
String mainWindowHandle = driver.getWindowHandle();
To get the main window handle:
Set<String> allWindowHandles = driver.getWindowHandles();
Switch to a different window:
for (String handle : allWindowHandles) {
if (!handle.equals(mainWindowHandle)) {
driver.switchTo().window(handle);
// Perform actions in the new window
driver.close(); // Close the new window
driver.switchTo().window(mainWindowHandle); // Switch back to the main window
}
}
8. CODING:
Reverse the String with the given input
Input: this is tree
Output: tree is this
package java;
public class ReverseString {
public static void main (String [] args) {
String input = “this is tree”;// Input string
System.out.println(“Input: ” + input);
// Split the string into words
String[] words = input.split(” “);
// Reverse the order of words manually
String reversed = “”;
for (inti = words.length – 1; i>= 0; i–) {
reversed += words[i];
if (i != 0) { // Add space between words, but not at the end
reversed += ” “;
}
}// Output the reversed string
System.out.println(“Output: ” + reversed);
}
}
Round – 2
1.How to handle multiple windows?
Get Window Handles: When a new window opens, use driver.getWindowHandles() to retrieve all available window handles.
Switch to a Specific Window: Use driver.switchTo().window(windowHandle) to navigate to the desired window.
Perform Actions in the Window: After switching, interact with the elements in the selected window as needed.
Switch Back to the Main Window: Once the interactions are complete, use the main window’s handle to switch back to it.
Refer: Round1 answer
2. Write a program, to print the frequency of all vowels in the given string “Welcome Capgemini” (15mins only)
Solution :1
package review;
public class Freq {
public static void main(String[] args) {
String input = “Welcome Capgemini”;
// Given string
int aCount = 0, eCount = 0, iCount = 0, oCount = 0, uCount = 0;
// Convert the string to lowercase to handle case insensitivity
input = input.toLowerCase();
// Iterate through the string and count vowels
for (int i = 0; i<input.length(); i++) {
char ch = input.charAt(i);
switch (ch) {
case’a’:
aCount++;
break;
case’e’:
eCount++;
break;
case’i’:
iCount++;
break;
case’o’:
oCount++;
break;
case’u’:
uCount++;
break;
}
}
// Output the frequency of each vowel
System.out.println(“Frequency of ‘a’: ” + aCount);
System.out.println(“Frequency of ‘e’: ” + eCount);
System.out.println(“Frequency of ‘i’: ” + iCount);
System.out.println(“Frequency of ‘o’: ” + oCount);
System.out.println(“Frequency of ‘u’: ” + uCount);
}
}
Solution 2:
Map<Character, Integer> vowelFrequency = new HashMap<>();
for (char ch : input.toCharArray()) {
if (“aeiou”.indexOf(ch) != -1) {
vowelFrequency.put(ch, vowelFrequency.getOrDefault(ch, 0) + 1);
}
}
vowelFrequency.forEach((vowel, count) -> System.out.println(“Frequency of ‘” + vowel + “‘: ” + count));
3.Write a code to select 3rd option from dropdown (Select Tag)
package review;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.support.ui.Select;
publicclassDropdownSelection {
publicstaticvoid main(String[] args) throwsInterruptedException {
// Initialize the ChromeDriver
ChromeDriverdriver = newChromeDriver();
// Navigate to the webpage containing the dropdown
driver.get(“your_webpage_url”); // Replace with the actual URL
// Locate the dropdown element using its ID, name, or other suitable locator
WebElementdropdownElement = driver.findElement(By.id(“dropdown_id”)); // Replace with the actual ID
// OR
// WebElementdropdownElement = driver.findElement(By.name(“dropdown_name”));
// OR
// WebElementdropdownElement = driver.findElement(By.xpath(“//select[@name=’dropdown_name’]”)); // Example XPath
// Create a Select object
Select dropdown = newSelect(dropdownElement);
// Select the 3rd option (index starts from 0)
dropdown.selectByIndex(2); // Index 2 represents the 3rd option
// OR, if you know the visible text:
// dropdown.selectByVisibleText(“Option 3 Text”); // Replace with the actual text
// OR, if you know the value attribute of the option:
// dropdown.selectByValue(“option3_value”); // Replace with the actual value
}
}
2. How do you handle synchronization issues?
Synchronization issues in Selenium occur when the WebDriver tries to interact with an element that is not yet ready, such as when the DOM is still loading or elements appear dynamically. To handle these issues, I primarily use the following approaches:
Explicit Wait:
I prefer using WebDriverWait with specific conditions, as it allows me to wait for elements or specific states like visibility, clickability, or presence. This ensures the script interacts with the element only when it is ready.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(“elementId”)));
Fluent Wait:
For scenarios requiring polling with a custom interval and exception handling, I use Fluent Wait. It gives me more flexibility when dealing with dynamic elements.
Wait<WebDriver> fluentWait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(20))
.pollingEvery(Duration.ofSeconds(2))
.ignoring(NoSuchElementException.class);
WebElement element = fluentWait.until(driver -> driver.findElement(By.id(“elementId”)));
Implicit Wait:
I use implicit wait as a fallback mechanism for global synchronization, but I ensure not to combine it with explicit wait to avoid unexpected behavior.
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
Page Load Timeout:
For ensuring that the entire page is loaded before performing any actions, I use the pageLoadTimeout.
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(20));
Avoid Thread.sleep:
I avoid using Thread.sleep as it introduces unnecessary delays and is not reliable. Instead, I focus on dynamic waits like explicit and fluent waits for better efficiency.
ROUND – 3:
1.You have 100’s of test case to execute and you have a short deadline how will u complete?
When faced with hundreds of test cases and a tight deadline, I would prioritize testing critical functionalities, utilize automation and parallel execution, and collaborate efficiently with the team. This approach ensures high-priority features are thoroughly tested within the given timeframe while maintaining quality standards.
2.How will u do parallel execution in cucumber there are 2 ways tell me both
In my experience as a software tester, parallel execution is crucial for minimizing test execution time, particularly in large-scale projects. In Cucumber, two popular methods for achieving parallel execution are using TestNG and the Cucumber JVM Parallel Plugin. Here’s my approach to both:
Using TestNG for Parallel Execution:
TestNG provides a structured and reliable way to achieve parallel execution by configuring the TestNG XML file.
Steps:
Create Runner Classes:
I create multiple runner classes, each mapped to specific feature files or tags, ensuring modularity and clarity.
Configure TestNG XML File:
I set up a TestNG XML file where parallel execution is enabled with the thread-count attribute.
Execute:
The TestNG XML file orchestrates parallel execution efficiently, and the results are captured using TestNG listeners or reporting tools like Extent Reports.
Using Maven Cucumber JVM Parallel Plugin:
For larger projects where scalability and automation are key, I leverage the cucumber-jvm-parallel-plugin. This approach generates runner classes dynamically based on configuration, saving manual effort.
Steps:
Add Plugin in pom.xml:
I configured the Maven plugin in the pom.xml file to enable parallel execution.
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<outputDirectory>target/generated-test-sources/cucumber</outputDirectory>
<featuresDirectory>src/test/resources/features</featuresDirectory>
<glue>com.example.stepdefinitions</glue>
<parallelScheme>SCENARIO</parallelScheme>
<useTestNG>true</useTestNG>
<threadCount>4</threadCount>
</configuration>
</execution>
</executions>
</plugin>
Execution:
I run the Maven command mvn clean test, which generates the runner classes dynamically and executes them in parallel based on the specified thread count.
I prefer TestNG when I need finer control over execution, such as running tests selectively or when working in a hybrid framework.
This is my go-to for large-scale projects with numerous feature files, as it reduces manual effort by dynamically generating runners and integrating seamlessly with CI/CD pipelines.
In both approaches, I ensure proper reporting and debugging by integrating tools like Extent Reports or Allure. While TestNG provides better control, the Maven plugin offers scalability and automation, making both indispensable in different contexts. As someone with extensive experience, I always choose the approach based on the project’s needs, team size, and CI/CD requirements.
3.All the members of your team are on leave, how will you take over the work on that day?
If all my team members are on leave, I would handle the situation by prioritizing critical tasks, reviewing documentation for clarity, and leveraging tools to streamline work. I’d communicate proactively with stakeholders to set expectations and seek backup support if needed. I’d stay focused, work systematically, and document progress for a smooth handover when the team returns. Finally, I’d reflect on gaps and suggest improvements to avoid similar dependencies in the future.
Conclusion
Clearing all three rounds of Capgemini’s interview process requires preparation, focus, and a structured approach. The questions shared in this blog aim to strengthen your technical foundation, improve your problem-solving skills, and prepare you for behavioral and situational questions asked in the managerial and HR rounds.
Remember, interviews are not just about answering questions but also about demonstrating your thought process, confidence, and ability to adapt to challenges. Take time to practice, review these questions, and align your responses with Capgemini’s core values and expectations.
Feel free to revisit this blog as you prepare and share it with your network to help others succeed as well. Wishing you the best of luck in your Capgemini interview – may you shine in all three rounds and secure your dream role!
Also Read: Selenium Interview Questions
Also Read: Technical Interview Questions
Also Read: Software Testing Interview Questions
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