• +(91) 8750050183
  • info@helpingtesters.com
  • helpingtesters

Top 50+ Automation Framework Software Testing Interview Questions

November 21, 2017 ,

1. What is a Framework?

The framework is an automation guideline for maintaining the consistency of testing, Minimum usage of code, Improves test structure, Less maintenance of code, Improve re-usability, Involvement of Non Technical testers in code, Reducing the training period of using the tool. 

2. What are the advantages of Test Automation framework?

  • Maximum coverage of Test cases
  • Reusability of code, they can be reused again and again, saving time for the entire organization/project team.
  • Recovery Scenario
  • Low-cost maintenance
  • Easy Reporting. It generates reports automatically after test execution
  • Minimal manual intervention
  • support for future enhancements
  • Maintaining the consistency of testing
  • Saves time
  • It is mostly used for regression testing
  • Automation testing is faster in execution
  • Easy for compatibility testing

3. Why Framework?

  • Easy maintainability
  • Easy to debug our scripts
  • Easy to run our scripts
  • East to incorporate changes in application
  • Easy to fix scripts on failure
  • East to create custom reports
  • Easy to make scripts
  • Easy to do configuration changes
  • Easy to understand application scripts

4. Why we use Framework?

We use the framework in order to organize and manage all the files and to finish all the tasks in a systematic approach.

5. What is the Test Automation Framework Development Challenges?

  • A Clear understanding of what needs to be achieved out of the test automation.
  • Identifying requirements from multiple areas to design Framework.
  • Tool identification

6. What are the various elements need to be taken into consideration for designing a framework?

  • Database communication
  • Logs
  • Error Handlers
  • Actions to be performed
  • Communication with automation tools
  • Custom Messages

7. List out the different types of Frameworks?

  • Data Driven Testing Framework
  • Keyword Driven Testing Framework
  • Hybrid Testing Framework
  • Behavior Driven Development Framework (BDD)
  • Module Based Testing Framework
  • Library Architecture Testing Framework
  • Page Object Model Framework
  • Page Object Model With Page Factory

8. How to prepare Customized HTML Report using TestNG in the hybrid framework?

Below are the 3 ways:

  • Junit: with the help of ANT.
  • TestNG: using inbuilt default.html to get the HTML report. Also, XST reports from ANT, Selenium, TestNG combination.
  • Using our own customized reports using XSL jar for converting XML content to HTML.

9. What is TestNG?

TestNG is a testing framework that overcomes the limitations of another popular testing framework called JUnit. The “NG” means “Next Generation”. Most Selenium users use this more than JUnit because of its advantages.

10. What are the advantages of TestNG over Junit?

  • Annotations are easier to understand
  • Test cases can be grouped more easily
  • Parallel testing is possible

11. What is Data Driven Framework?

Data Driven Framework is automation testing framework. It is used for creating a set of test data in excel sheet and that set of test data imported in automation testing software tool and after test execution, a set of the result generated in excel sheet. Because it is handling a set of data so-called data-driven.

12. What are the advanta\89*8\91ges of Data Driven Framework?

  • Provide re-usability and reduces the total number of scripts required to cover all test scenarios combinations.
  • Will not affect the test script code if any changes are done in test data matrix.
  • A single test scenario can be executed for different test data values.

13. What is Hybrid Framework?

The hybrid framework is a combination of data-driven and keyword driven framework which is used for a large application which has good no of test cases to execute.

14. What are the advantages of Hybrid Framework?

  • Code reusability
  • Low code maintenance
  • Structured test cases.

15. What is Page Object Model?

Page Object Model is a kind of design in which each page is made as a java class. Each page has an object of the corresponding page and action to the object. Each object has the corresponding method in POM. Based on the action of the object method name has been given.

16. What are the advantages of Page Object Model?

  • Easy of test maintenance of code
  • Reduces the duplication of code.
  • Need to change only the code within the page objects if the UI changes for any page.
  • Make code more readable
  • The code becomes less and optimized.
  • UI flow and object has been separated from test scripts
  • Methods name are more meaningful
  • Test cases are easy to understand

17. What is the use of @Listener annotation in TestNG?

TestNG listeners are used to configure reports and logging.

18. What is the use of TestNG in selenium?

Using TestNG framework we can,

  • Generate detailed Html Test Reports
  • We can execute tests parallel
  • Group Test Cases
  • Parameterize Tests
  • Execute multiple programs using XML file etc……..

19.What are the important TestNG Annotations?

Important TestNG Annotations are:

@Test – Annotation for every Test (Method)

@BeforeMethod – pre-condition for every test case in a program.

@AfterMethod – Post condition for every test case in a program.

@BeforeClass – precondition for all test cases in a program/class

@AfterClass – postcondition for all test cases in a program/class

@BeforeTest – @BeforeTest is called once before execution of any test method

@AfterTest – postcondition for all test cases in multiple classes/programs

20. How to skip a @Test method from execution?

You can use the inside @Test method to skip a test case from test execution.

throw new SkipException(“Skipping the test”);

21. How to define the priority of @Test method? Also, mention its usage?

You can set priority for TestNG @Test annotated methods as shown in the following example.

@Test(priority=0)

By setting priority, you can manage @Test method execution sequence as per our requirement. That means @Test method with priority = 0 will run 1st and @Test method with priority = 1 will execute 2nd and so on.

22. List out specify any 6 assertions of TestNG to be used in a Selenium WebDriver?

There are multiple assertions available In TestNG, but generally, we use the following assertions in out test cases.

  • assertEquals
  • assertNotEquals
  • assertFalse
  • assertTrue
  • assertNull
  • assertNotNull

23. List out the benefits of TestNG over Junit?

TestNG has following benefits over JUnit Framework

  • TestNG annotations are more logical and easier to understand.
  • Unlike JUnit, TestNG does not require to declare @BeforeClass and @AfterClass.
  • There is no method name constraint in TestNG framework.
  • In Selenium TestNG projects, there is no need to extend any class.
  • In TestNG, it is possible to run Selenium test cases parallel.
  • TestNG supports grouping of test cases which was not possible in JUnit.
  • TestNG allows you to execute the test cases, based on the group
  • TestNG permits you to determine the dependent test cases. Every test case is autonomous to other test cases.

24. How can you disable a test in TestNG?

To disable the test case, you can use the following annotation.

@Test(enabled = false)

25.What does the test timeout mean in TestNG?

The test timeout in TestNG is nothing but the time allotted to perform unit testing. If the unit test fails to finish in that specific time limit, TestNG will abandon further testing and mark it as failed.

26. List out various ways in which TestNG can be invoked?

TestNG can be invoked in different ways like

  • Start directly from the Eclipse IDE
  • With ant build tool
  • From the command line prompt
  • Using IntelliJ’s

27. How to parameterize tests in TestNG?

There are two different ways TestNG allows us to pass parameters directly to test methods,

  • XML file
  • Using DataProviders

28. Which time unit we provide on @Test method level or test suite level?

Time unit which we provide on @Test method level or test suite level is in milliseconds.

29. What are two main ways to generate a report with TestNG?

  • Listeners: For implementing a listener class, the class has to implement the testng.ITestListener interface. These classes are notified at runtime by TestNG when the test starts, finishes, fails, skips, or passes.
  • Reporters: For implementing a reporting class, the class has to implement a testng.IReporter interface. These classes are called when the whole suite run ends. The object containing the information of the whole test run is passed to this class when called.

30. What are the features of TestNG?

  • TestNG uses more Java and Object Oriented features.
  • Supports testing integrated classes (e.g., by default, no need to create a new test class instance for every test method).
  • Separate compile-time test code from run-time configuration/data info.
  • Flexible runtime configuration.
  • Introduces ‘test groups’. Once you have compiled your tests, you can just ask TestNG to run all the “front-end” tests, or “fast”, “slow”, “database”, etc…
  • Supports Dependent test methods, parallel testing, load testing, partial failure.
  • Flexible plug-in API.
  • Support for multi-threaded testing.

31. How to pass parameter through the testng.xml file to a test case?

You can pass the parameter using the below syntax in the testng.xml file.

<parameter name=”browser” value=”xxx” />

32. How does TestNG allow you to state dependencies?TestNG supports two ways to declare the dependencies.

  • Using attributes dependsOnMethods in @Test annotations.
  • Using attributes dependsOnGroups in @Test annotations.

33. What is Annotation?

Annotation is a predefined metadata or test which is attached to a function, that function can be considered as a test function if the annotation is @Test.

34. What are the Annotations used in TestNG?

The list of Annotations present in TestNG are.

  • @BeforeMethod
  • @AfterMethod
  • @BeforeClass
  • @AfterClass
  • @BeforeTest
  • @AfterTest
  • @BeforeSuite
  • @AfterSuite
  • @DataProvider
  • @Test

35. What is Data Provider?

Data Provider is something which helps you to run a test case with multiple sets of data.

36. What is the return type of Data Provider?

The return type of Data Provider is basically object array.

37. What is the difference between Junit and TestNG?

  • Reporting is better in TestNG. In Junit if we want to generate Html reports we want to run through ANT or Maven mandatory which is not the case in TestNG.
  • Using TestNG Data provider is much easier than using the equivalent of Data Provider in JUit.
  • Integrating Selenium grid with TestNG is much easier than Junit.

38. What is the difference between assert and verify command?

Both Assert and Verify are used to verify the result.If an assertion fails the flow stops but if verification fails the flow doesn’t stop.

39. What is Assertion? Why we go for Assertions?

The assertion is used to validate expected result and the actual result.

Syntax: Assert.assertEquals(actual,expected);

Ex: Assert.assertEquals(“A”, ”B”);

40. Is possible to write multiple Test cases in single class?

Yes, in a single class we can write multiple Test Cases.

41. Which problems are faced in TestNG?

  • If an assertion fails, the program stops
  • The default report of TestNg which TestNg gives in the test output folder is not as impressive. We have to use ANT or Maven to generate better reports.
  • Sharing the same webdriver instance among multiple test cases.

42. In TestNG, I have some test’s line

Test1

Test2

Test3

Test4

Test5

I want to run execution order as

Test5

Test1

Test3

Test2

Test4 ?

Package Java;

import org.testng.annotations.Test;

public class TestNG_Tests {

@Test(priority=2)

public void test1() {

     System.out.println(“test1”);

}

@Test(priority=4)

public void test2() {

     System.out.println(“test2”);

}

@Test(priority=3)

public void test3() {

     System.out.println(“test3”);

}

@Test(priority=5)

public void test4() {

     System.out.println(“test4”);

}

@Test(priority=1)

public void test5() {

     System.out.println(“test5”);

}

}

Output:

Passed: test5

Passed: test1

Passed: test3

Passed: test2

Passed: test4

43. How to execute the (single) selected method in TestNg?

By using include or exclude we can execute single selected method in TestNG. If a class have multiple methods and if we want to run one method out of multiple methods, we can keep run mode in the excel file and we can use include or exclude tag.

44. What are the Annotations used in Junit?

The list of Annotations present in Junit are.

  • @Before
  • @After
  • @BeforeClass
  • @AfterClass
  • @Ignore
  • @Test

45. What is the difference between @BeforeClass and @BeforeMethod in TestNG?

@BeforeClass will execute before every class whereas @BeforeMethod will execute before every @Test method.

46. List out the different attributes for @Test annotation?

  • dataProvider
  • alwaysRun
  • expectedExceptions
  • timeOut
  • dependsOnGroups
  • dependsOnMethods
  • enabled
  • priority etc….

47. What is the use of testng.xml file?

By using testng.xml we can create suite files, groups, methods and also listeners. We can mark tests for parallel execution. We can trigger testng.xml file from the command prompt or through Jenkins.

48. What is the use of pom.xml file?

By using pom.xml file we can execute test suites in maven. We can maintain jar files well structured.

49. What is the difference between @BeforeSuite and @AfterSuite method in TestNG?

@BeforeSuite: This annotation represents to run before all tests in this suite have run.

@AfterSuite: This annotation represents to run after all tests in this suite have run.

50. What is the difference between @BeforeMethod and @AfterMethod in TestNG?

@BeforeMethod: This annotation represents to run before each test method

@AfterMethod: This annotation represents to run after each test method

51. What is the difference between @BeforeTest and @AfterTest method in TestNG?

@BeforeTest: This annotation represents to run before any test method belonging to the class

@AfterTest: This annotation represents to run after all the test method belonging to the class

52. What is the difference between @BeforeClass and @AfterClass method in TestNG?

@BeforeClass: This annotation represents to run before the first test method in the current class is invoked.

@AfterClass: This annotation represents to run after all the test methods in the current class have been run.

53. What is the use of alwaysRun in TestNg?

alwaysRun method will always  run even if it depends on a method which failed, If set to true

54. What is the use of @Factory in TestNg?

@Factory method returns objects that will be used by TestNG as Test classes

55. Tell me a login page script in TestNG?

Package Java;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.DataProvider;

import org.testng.annotations.Test;

public class Logintest {

@Test(dataProvider = “getData”)

public void doLogin(

String username ,

String password,

String browser ,

String expectedResult)

{

WebDriver driver = null;

if(browser.equals(“Mozilla”))

    driver = new FirefoxDriver();

else if(browser.equals(“Chrome”)) {

System.setProperty(“Webdriver.chrome.driver” , “F:\\chromedriver.exe”);

}

}

}

@DataProvider

public Object[] [] getData() {

Object data[] [] = new Object[2] [4];

data[0] [0] = “U1”;

data[0] [1] = “P1”;

data[0] [2] = “Mozilla”;

data[0] [3] = “Success”;

data[1] [0] = “U2”;

data[1] [1] = “P2”;

data[1] [2] = “Chrome”;

data[1] [3] = “fail”;

return data;

}

}

Leave a Reply

Your email address will not be published.

Broaden Your Knowledge. Enroll Today.

Our tutoring services on software testing courses online offer information on a wide variety of courses, ranging from Web Security and Software Testing courses to selenium online training to Mobile Automation Testing. Whatever criterion you need help with concerning advanced technological functions and operations, we’ve got you covered. We also use real world examples and scenarios for solving examples and projects, enhancing your knowledge and broadening your horizon.