Testleaf

EPAM Interview Questions with Answers

Epam Interview Questions

Epam Interview Questions: Part 2

As promised, here’s Part 2 of our interview questions series! In this post, we’ll cover 19 more essential questions to help you strengthen your knowledge and boost your confidence. If you haven’t checked it yet, read Part 1 here.

Q1) How can we execute particular test cases for 3 times in testing?

We can execute a particular test case three times in TestNG by using the invocationCount attribute in the @Test annotation. This tells TestNG to run that test method the specified number of times. 

Example: 

@Test(invocationCount = 3)
public void executeThreeTimes() (
System.out.println(“This test is executed three times.”);
}

Explanation: 

invocationCount = 3:
This attribute ensures that the executeThreeTimes() method is invoked three times during a single test run. 

Use Case: This is useful for scenarios like checking for flaky tests, load testing a particular method, or simply ensuring consistency. 

If needed, you can also run these invocations in parallel by adding the threadPoolSize attribute. For instance: 

@Test(invocationCount = 3, threadPoolSize = 2)
public void executeThreeTimesInParallel() {
System.out.println(“Thread: “);
}

Q2) How we execute 40 test cases alone among 500 test cases? 

In our projects, to run only a specific subset—say, 40 out of 500 test cases—we typically use TestNG’s grouping mechanism. Here’s how it works: 

     1) Tagging Tests with Groups:
     We annotate our test methods with a group name that represent
     the subset we want to run. For example: 

@Test(groups = {“smoke”})
public void testCase1() {
// test logic
}

     We apply the same group (like “smoke”) to all the 40 test cases we wish to execute. 

     2) Configuring testng.xml:
     In our testng.xml file, we specify that only tests belonging to the “smoke” group should run: 

https://testng.org/testng-1.8.dtd (doctype)
<!DOCTYPE suite SYSTEM “https://testng.org/testng-1.0.dtd”>
<suite name=”Subset Suite”>
<test name=”Run 40 Smoke Tests”>
<groups>
<run>
<include name=”smoke”/>
</run>
</groups>
<classes>
<class name=”com.sample.class1″/>
<class name=”com.sample.Class2″/>
<!– List all classes that contain your smoke tests
</classes>
</test>
</suite>

Q3)How we execute test cases in a parallel way?

In our automation framework, we execute test cases in parallel using TestNG’s built-in parallel execution features. There are two primary ways to achieve this: 

1.  Configuring Parallelism via testng.xml: 

What It Does: You can set the parallel attribute in your testng.xml file to run tests, classes, or methods concurrently. You can also specify the thread-count to control how many threads will be used. 

https://testng.org/testng-1.0.dtd (doctype)
<!DOCTYPE suite SYSTEM “https://testng.org/testng-1.0.dtd”>
<suite name=”Suite” parallel=”methods thread-count=”5″>
<test name=”ParallelTests”>
<classes>
<class name=”com.example.YourTestClass”/>
</classes>
</test>
</suite>

parallel=”methods” indicates that individual test methods will run in parallel. 

thread-count=”5″ limits the number of concurrent threads to 5.
 

2. Using Annotations (Invocation Count and Thread Pool): 

What It Does:
At the method level, you can use the invocationCount attribute to run a test multiple times and the threadPoolSize attribute to specify the number of threads to use for those invocations. 

Example: 

@Test(invocationCount = 10, threadPoolsize = 3)
public void concurrentTest() {
System.out.println(“Running on thread: “);
// Test logic here…
}

This test method is executed 10 times. 

Up to 3 threads will be used concurrently for these invocations. 

3. Benefits and Considerations: 

Benefits: 

Reduced Execution Time: Running tests concurrently can significantly speed up the overall test suite execution. 

Resource Optimization: Parallel tests make efficient use of available hardware resources. 

Considerations: 

Thread Safety: Ensure that your tests do not share mutable state or conflicting resources. 

Resource Management: Be cautious with external dependencies (like databases or files) to avoid conflicts during parallel execution.

Learn how to answer Top 20 Java Interview Questions effectively.

Q4) We have a LinkedList with some elements. How do you access the elements?

   1)  Using the get(index) Method: 

Usage: Retrieve an element by its index. 

Note: Since LinkedList is a doubly-linked list, accessing an element by index has O(n) time complexity. 

Example: 

LinkedList<String> list = new LinkedList<>();
list.add(“Apple”);
list.add(“Banana”);
list.add(“Cherry”);
// Access element at index 1 (Вапапа)
String element = list.get(1);
System.out.println(“Element at index 1: ” + element);    

2)  Using an Enhanced For Loop (For-Each): 

Usage: Iterate over each element. 

Example: 

for (String fruit: list) {
System.out.println(fruit);
}

3) Using an Iterator: 

Usage: Traverse the LinkedList with an Iterator. 

Example: 

Iterator<String> iterator = list.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}

4) Using a ListIterator: 

Usage: Traverse the list in both directions (forward and backward). 

Example: 

 ListIterator<String> listIterator = list.listIterator();
while (listIterator.hasNext()) {
System.out.println(listIterator.next());
}
 

Q5) How do you make some test cases should not run in testNG?

There are a couple of simple ways to prevent certain test cases from running in TestNG: 

1. Disable the Test Using the enabled Attribute: 

You can annotate a test method with @Test(enabled = false). This tells TestNG to ignore that test during execution. 

@Test(enabled = false)
public void testThatShouldNotRun() {
// This test won’t run.
}

2. Exclude Tests by Grouping in testng.xml: 

You can assign tests to specific groups and then configure your testng.xml to exclude those groups. 

Example: 

@Test(groups = {“exclude”})
public void testThatShouldNotRun() {
// This test is assigned to the “exclude” group.
}

In testng.xml, you can exclude that group: 

https://testng.org/testng-1.8.dtd (doctype).
<!DOCTYPE suite SYSTEM “https://testng.org/testng-1.0.dtd”>
<suite name=”Suite”>
<test name=”Test”>
<groups>
<run>
<exclude name=”exclude”/>
</run>
</groups>
<classes>
<class name=”com.testleaf.classA”/>
</classes>
</test>
</suite>

 Q6) I have 5 @test in one class, when BeforeTest and @BeforeMethod will run? Explain

@BeforeTest: 

When It Runs:
The @BeforeTest method runs once before any of the test methods in the <test> tag of your testng.xml file. 

Scope:
It applies to all classes and test methods defined within that <test> tag. 

Example:
If your testng.xml defines one <test> that includes your class, the @BeforeTest method will execute once before the 5 test methods in your class run. 

@BeforeMethod: 

When It Runs:
The @BeforeMethod method runs before each @Test method. 

Scope:
It applies to every test method in the class. 

Example:
With 5 @Test methods in the class, the @BeforeMethod will run 5 times (once before each test). 

Example: 

public class SampleTests {
@BeforeTest
public void beforeTest() {
System.out.println(“BeforeTest: Run once before all tests in this <test> tag.”);
}
@BeforeMethod
public void beforeMethod() {
System.out.println(“BeforeMethod: Run before each test method.”);
}
@Test
public void test1() {
System.out.println(“Test 1 executed.”); }
@Test
public void test2() {
System.out.println(“Test 2 executed.”);
}
@Test
public void test3() {
System.out.println(“Test 3 executed.”);
}
@Test
public void test4({
System.out.println(“Test 4 executed.”);
}
@Test
public void tests() {
System.out.println(“Test 5 executed.”);
}
}

OUTPUT: 

[RemoteTestNG] detected TestNG version 7.4.8
BeforeTest: Run once before all tests in this <test> tag.
BeforeMethod: Run before each test method.
Test 1 executed.
BeforeMethod: Run before each test method.
Test 2 executed.
BeforeMethod: Run before each test method.
Test 3 executed.
BeforeMethod: Run before each test method.
Test 4 executed.
BeforeMethod: Run before each test method.
Test 5. executed.
PASSED: test2
PASSED: tests
PASSED: test1
PASSED: test4
PASSED: test3
====================================
Default test
Tests run: 5, Failures: e, Skips: e
====================================
 

One to one mentorship

Q7) How to take screenshot?

In my automation projects, I take screenshots using Selenium’s built-in TakesScreenshot interface. This interface provides the getScreenshotAs method that allows you to capture the current state of the browser as an image. Here’s a simple example. 

File srcFile = driver.getScreenshotAs (OutputType.FILE);
File destFile = new File(“screenshot.png”);
FileUtils.copyFile(srcFile, destFile);

Q8) What report you are using?

In my automation projects, I use Extent Reports for generating test reports. 

Why Extent Reports? 

Interactive and Visually Appealing:

Extent Reports generate HTML reports that are easy to read and navigate, with rich visuals and dashboards displaying the test execution summary. 

Detailed Test Information:

It allows us to attach detailed logs, screenshots, and other artifacts to individual tests. This makes it easier to diagnose issues when tests fail. 

Real-Time Reporting:

Reports are generated in real-time as tests execute, which helps in monitoring test progress during long test runs. 

Integration:

Extent Reports integrate seamlessly with testing frameworks like TestNG and JUnit, and they work well with Selenium for web automation. 

Customization:

We can customize the look and feel of the reports, including themes, charts, and metadata (like system info, environment details, etc.).

 

Q9) How do you handle multiple test data in your project?

In our projects, we handle multiple test data sets using a data-driven approach. This involves separating our test logic from the actual data, which allows us to run the same tests with different inputs without changing the code. Here’s how we do it: 

     1) TestNG DataProvider: 

     We use TestNG’s @DataProvider to supply multiple sets of test data. This annotation allows a single test method to be executed multiple times with different           data sets defined in an Object[][] array. 

@DataProvider (name = “loginData”)
public Object[][] getLoginData() {
return new Object[][] {
{“user1”, “password1”},
{“user2”, “password2”},
{“user3”, “password3”}
};
}
@Test(dataProvider = “loginData”)
public void testLogin(String username, String password) {
// code to perform login and verify results
}

}

 

     2) External Data Sources:

     For more complex data sets, we read test data from external sources like Excel, CSV, or JSON files. We use libraries such as Apache POI for Excel or OpenCSV       for CSV files. This helps in managing large and changing data sets without altering the test code. 

     Parameterization via XML:

     We sometimes use TestNG’s XML configuration to pass parameters to our tests. This is useful for environment-specific configurations or when there’s a small         set of static data. 

Benefits: 

Reusability: Test logic is separated from test data, so the same test method can validate multiple scenarios. 

Maintainability: Updating test data doesn’t require changes in the code; data is managed externally. 

Scalability: It’s easy to add new test cases by simply appending more data sets. 

Related Posts: https://blog.testleaf.com/selenium-interview-questions/ 

 Q10) What lib you are using for API?

In my API automation projects, I primarily use REST-assured as the library for API testing. 

REST-assured is a Java DSL that simplifies testing RESTful web services. It provides a fluent and easy-to-read syntax for making HTTP requests (like GET, POST, PUT, PATCH, DELETE, etc.) and asserting responses. This library integrates well with other testing frameworks such as TestNG or JUnit and supports JSON and XML response parsing, authentication, and custom assertions. 

Example: 

public class APITest {
@Test
public void testGetEndpoint() {
given()
.baseuri(“https://api.example.com”)
.header(“Content-Type”, “application/json”)
.when()
.get(“/users”)
.then()
.statusCode (200)
.body(“size()”, greater Than (0));
}

Q11) What are all the HTTP methods you have in API?

In API testing and automation, the methods usually refer to the HTTP methods that define the type of action to be performed on the resource. The common HTTP methods used in APIs are: 

1. GET: 

Purpose: Retrieve data from a server. 

Characteristics: Safe and idempotent (repeating the same GET should produce the same result). 

2. POST: 

Purpose: Create a new resource or submit data to the server. 

Characteristics: Not idempotent; multiple identical POST requests might create multiple resources. 

3. PUT: 

Purpose: Update an existing resource completely by replacing it with new data. 

Characteristics: Idempotent; multiple PUT requests with the same data should result in the same resource state. 

4. PATCH: 

Purpose: Partially update an existing resource (i.e., modify only certain fields). 

Characteristics: Not strictly idempotent depending on how the API is designed but generally used for partial updates. 

5. DELETE: 

Purpose: Remove a resource from the server. 

Characteristics: Idempotent; deleting an already deleted resource generally returns the same status. 

6. HEAD: 

Purpose: Retrieve the headers for a resource, without the response body. 

Characteristics: Useful for checking what a GET request would return before actually making it. 

7. OPTIONS: 

Purpose: Describe the communication options for the target resource, such as supported methods. 

Characteristics: Often used in handling Cross-Origin Resource Sharing (CORS) or to understand the API’s capabilities.
 

Q12) 3 Difference between post and get method?

GET Method: 

     1. Purpose:      

      GET is used to retrieve data from a server. Think of it as asking, “Can you show me this information?” 

     2. How It Sends Data: 

     Data is sent as part of the URL. For example: 

     http://example.com/search?query=something 

     This means the information is visible in the browser’s address bar. 

     3. Visibility and Limitations: 

     Because the data is in the URL, it can be seen by anyone who looks at it. 

     URLs have a length limit, so you can’t send a large amount of data. 

     4. Caching and Bookmarking: 

     GET requests can be cached by browsers (stored for faster access later) and bookmarked (saved for future use). 

     5. Idempotency: 

     GET is considered idempotent, which means if you send the same GET request multiple times, the result will be the same and it doesn’t change anything on         the server. 

POST Method: 

     1. Purpose:      

      POST is used to send data to a server, usually to create or update resources. Think of it as submitting a form, like “Please save this new information.” 

     2. How It Sends Data: 

     Data is sent in the body of the HTTP request, not in the URL. 

     This means the data is not visible in the browser’s address bar. 

     3. Visibility and Limitations: 

     Since data is hidden in the request body, it’s more secure for sensitive data (although for true security, you should also use HTTPS). 

     There is no strict URL length limit, so you can send larger amounts of data. 

     4. Caching and Bookmarking: 

     POST requests are generally not cached by browsers. 

     You cannot bookmark a POST request because the data is not visible in the URL. 

     5. Idempotency: 

     POST is not idempotent by default. This means if you send the same POST request multiple times, it might create multiple entries or cause other changes on       the server. 

Online Classes

Q13) What authentication mechanisms have you used in your projects?

I have primarily implemented two types of authentication: 

     1. Basic Authentication: 

     Description:
     Uses a username and password encoded in Base64 to secure API endpoints. 

     Usage Example:
     Commonly used for simple API authentication in test scenarios, where the credentials are sent in the HTTP header.
 

     2. Token-Based Authentication (OAuth 2.0): 

     Description:
     Uses access tokens to verify user identity and grant access to secured resources. 

     Usage Example:
     Employed in projects that require enhanced security for API interactions, where a token is generated after validating credentials and then used for subsequent       requests. 

 

 Q14) What build management tool you are using?

In my automation projects, I use Maven as the build management tool. Maven is an open-source build automation tool primarily used for Java projects. It simplifies the entire build lifecycle—from compiling code to packaging and deploying applications—using a single configuration file called the pom.xml.

Key benefits of Maven include: 

     1. Automatic Dependency Management:       

     Maven downloads and manages all the necessary libraries and plugins from central repositories, which saves a lot of time and reduces version conflicts. 

     2. Standardized Project Structure:

     It enforces a consistent directory layout (such as src/main/java for source code and src/test/java for tests), which makes the project easier to understand and         maintain. 

     3. Consistent Build Lifecycle:

     Maven defines a standard set of build phases (clean, compile, test, package, install, deploy) that ensure our projects build the same way across different                     environments. 

     4. Extensibility with Plugins:

     The rich ecosystem of Maven plugins allows us to integrate tasks like code quality analysis, documentation generation, and automated deployment seamlessly         into the build process. 

     5. IDE and CI/CD Integration:

     Maven integrates very well with popular IDEs like Eclipse and IntelliJ IDEA, as well as continuous integration tools like Jenkins, which streamlines both local       development and automated build pipelines. 

Q15) What is the Benefits of Maven?

What is Maven? 

Maven is a build automation and project management tool primarily used for Java projects. It uses a configuration file called pom.xml (Project Object Model) to manage project dependencies, build processes, and plugins. Maven standardizes the project structure and automates many tasks, making it easier to build, test, and deploy applications consistently. 

Benefits of Maven: 

  • Automatic Dependency Management:
    Maven automatically downloads and manages third-party libraries your project needs, so you don’t have to manually include JAR files or resolve version conflicts. 
  • Standardized Project Structure:
    It enforces a common folder layout, making projects more uniform and easier for new developers to understand. 
  • Consistent Build Process:
    Maven defines a fixed build lifecycle (e.g., clean, compile, test, package, install, deploy) that ensures your project builds the same way every time across different environments. 
  • Extensible with Plugins:
    A vast ecosystem of plugins automates tasks such as compiling code, running tests, generating reports, and packaging the application, reducing manual effort. 
  • Integration with IDEs and CI/CD Tools:
    Maven integrates seamlessly with popular IDEs (like Eclipse and IntelliJ IDEA) and continuous integration systems (such as Jenkins), which streamlines the development and deployment process. 

Q16) What CI/CD tools are you using? 

I use a combination of Maven, Git, and Jenkins in my CI/CD pipeline: 

Maven:
Manages build automation and dependency management. It compiles the code, runs tests, and packages the application. 

Git:
Serves as the version control system to manage source code and track
changes. 

Jenkins:
Acts as the CI/CD server to automate the integration, testing, and 

deployment processes, triggering builds whenever changes are pushed to Git. 

This combination allows me to efficiently manage code, automate builds, and streamline deployment processes. 

 

Q17) Is git and github is same or different?

Git and GitHub are related but not the same: 

Git: 

A distributed version control system (VCS) used to track changes in source code during software development. 

It is a command-line tool (and also available via GUIs) that runs locally on your computer. 

Git allows you to manage revisions, branches, merges, and more. 

GitHub: 

A web-based hosting service for Git repositories. 

It provides a platform to store, share, and collaborate on Git repositories online. 

GitHub offers additional features like issue tracking, pull requests, and code reviews. 

In summary, Git is the tool for version control, while GitHub is a service that helps you host and manage your Git repositories online. 

Selenium training in chennai
Q18) What is the command for PUSH ?

The Git command for pushing your local commits to a remote repository is: 

git push <remote> <branch> 

For example, if your remote is named origin and your branch is main, you’d use: 

git push origin main 

Key Points: 

  • <remote>:
    This is the name of your remote repository (commonly origin). 
  • <branch>:
    This is the name of the branch you want to push (for example, main or master). 
  • Authentication:
    Depending on your repository setup, you might be prompted for credentials or use SSH keys for authentication. 
  • iv) Example Workflow:
  1. Make your changes.
  2. Stage your changes:

            git add .
       3. Commit your changes: 

           git commit -m “Your commit message”
      4. Push your changes: 

         git push origin main 

Get expert tips on tackling Test Automation Framework Interview Questions.

 Q19) What is super keyword?

 Definition:

  The super keyword in Java is a special reference used within a subclass to refer to its immediate parent class. It allows you to access methods, fields, and                constructors of the parent class. 

Purpose: 

Reusability:

Enables a subclass to reuse or extend the functionality of its parent class without rewriting code. 

Maintenance:

By calling parent’s methods or constructors, changes in the parent class propagate automatically to subclasses. 

Keyword:
super 
Usage Context: 
  • Used in method overriding to call the overridden method in the parent class. 
  • Used in constructors to invoke a specific constructor from the parent class. 
  • Can also be used to access hidden fields if the subclass defines a variable with the same name as in the parent. 

Selenium Example: 

Usage in Selenium:

While Selenium’s built-in classes themselves (like RemoteWebDriver, ChromeDriver, etc.) already use inheritance, you might create custom classes in your automation framework where you extend Selenium classes. 

Example Scenario:
public class CustomChromeDriver extends ChromeDriver {
// Constructor: calls the parent ChromeDriver constructor
public CustomChromeDriver() {
super();
}
// Custom method that navigates to a URL using the parent’s get() method
public void customNavigate(String url) {
super.get(url);
System.out.println(“Navigated to:” + url);
}
public static void main(String[] args) {
// Create an instarice of CustomChromeDriver
ChromeDriver driver = new CustomChromeDriver();
// Use the custom navigation method
((CustomChromeDriver) driver).customNavigate(“https://www.example.com”);
// Quit the driver
driver.quit();
}
}

Explanation: 
  • Here, super() is used to call the ChromeDriver constructor. 
  • You can also use super.get(…) if you want to ensure you are calling the original get() method from the parent class after performing additional logic. 

Conclusion 

These EPAM interview questions not only test your understanding of a well-structured test automation framework but also your ability to write clean, efficient Java code for common programming tasks. By explaining your hybrid framework—built on the POM design pattern and integrated with tools like Selenium, TestNG, and Maven—you can demonstrate a solid foundation in automation best practices. Moreover, solving the array manipulation problem showcases your coding skills and attention to detail. 

I hope this guide helps you prepare for your EPAM interview by reinforcing both your theoretical knowledge and practical coding abilities. Good luck on your journey and remember to keep refining your skills as you tackle more complex challenges in the world of automation and software development! 

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

                                                                         LinkedIn Logo

Accelerate Your Salary with Expert-Level Selenium Training

X