TestNG has very good feature to enable or disable selenium webdriver @Test method. During test execution, If you do not wants to execute specific @Test method from test class then you can directly disable It using TestNG property enabled = false. It Is something like excluding @Test method from execution as described In THIS POST.

Part 15

68 : What Is the usage of testng.xml file?

Answer : In selenium WebDriver software testing tool, We are using testng.xml file to configure our whole test suite In single file. Few of the tasks which we can specify In testng.xml file are as bellow.

preserve-order Is very Important attribute In TestNG. In Selenium WebDriver test execution, Many times peoples are complaining like my test cases execution not runs In correct sequence as given In testng.xml file but they are being executed In random sequence(unpredictable order). Actually they have copy pasted testng.xml file from somewhere with attribute preserve-order="fasle" but they don't know meaning of this attribute. Let me try to explain you meaning of this attribute.

Part 14

63 : What Is TestNG?

Answer : TestNG Is Open Source(Freeware) framework which Is Inspired from NUnit and JUnit with Introducing few new features and functionality compared to NUnit and JUnit to make It easy to use and more powerful.

We have learnt how to create and store multiple @DataProvider methods In single class file called dataProvider_Repository.java and then we can use those data In different test case execution as described In THIS PAGE. Using this, We can manage data of all test cases very easily In single file and If you wants to modify test data of any test case, You have to modify only single file.

Part 13

58 : Tell me main features of JUnit.

Answer : JUnit features are as bellow.
  • JUnit Is unit software testing framework. So It helps software developers to create and run unit test cases very easily.

We have already learnt how to create and use testng data providers In selenium webdriver test cases In THIS POST. Also we have used testng data providers In Selenium WebDriver Data Driven Framework creation so all you are now very familiar with testng data providers and how to use them In our automation test case creation.

Part 12

53 : Which Is the latest version of JUnit.

Answer : Current latest version of JUnit Is 4.12-beta-2. This can change In future. To check latest released version of JUnit, You can Visit JUnit Official WebSite.

Sometimes you need to execute multiple test cases at same time to save test execution time. TestNG has very good feature to execute test cases/classes In parallel to each other means you can execute two different test cases In two different windows of same browser simultaneously. If you remember, We have already learnt how to execute two different tests In two different browsers(Example : Firefox and Google Chrome) simultaneously In THIS POST.

Part 11

48 : Can you tell me a syntax to close current webdriver Instance and to close all opened webdriver Instances?

Answer :
Yes, To close current WebDriver Instance, We can use Close() method as bellow.

Earlier in previous post, We have learnt how to set test execution priority of WebDriver test cases If you have multiple tests In same class. TestNG has one more very useful feature of setting test execution dependency. Depends on method in testng means If one @Test method fails or skipped from execution then It's dependent @Test method must not be executed. So you can set test execution dependency using dependsonmethods in selenium.

Part 10

46 : Can we perform drag and drop operation In Selenium WebDriver? Tell me a syntax to drag X element and drop It On Y element.
Answer : Yes, We can perform drag and drop operation using selenium webdriver software testing tool's Advanced User Interactions API. Syntax Is like below.

We can set test execution priority for selenium WebDriver @Test annotation methods. If there Is single @Test annotation method In your test class then you do not need to set test execution priority but supposing you have multiple @Test annotation methods In single test class then many of you may face Issue like @Test method's execution sequence Is different than the actual sequence.