Showing posts with label webdriver with testng. Show all posts
Showing posts with label webdriver with testng. Show all posts

Some times when we browsing software web application, Display some unexpected alerts due to some error or some other reasons. This kind of alerts not display every time but they are displaying only some time. If you have created webdriver software automation test case for such page and not handled this kind of alerts In your code then your script will fail Immediately If such unexpected alert pop up displayed.

Alerts, Confirmation and Prompts are very commonly used elements of any software webpage and you must know how to handle all these popups In selenium webdriver software automation testing tool. If you know, Selenium IDE has many commands to handle alerts, confirmations and prompt popups like assertAlertassertConfirmationstoreAlertverifyAlertPresent, etc.. First of all, Let me show you all three different popup types to remove confusion from your mind and then we will see how to handle them In selenium webdriver.

If you know, we have already learn about testng hard assertions (Example assertEquals, assertNotEquals, etc..) which we can use In our webdriver test for software web application. Hard assertion examples links are given on THIS PAGE. View all those examples one by one to learn hard assertions. Let me tell you one thing about hard assertions, When hard assertion will fail Inside any test method, remaining execution of that specific test method will be aborted. Now If you wants to continue remaining test part execution even If assertion fails and also you wants to report assertion failure In testng result report then you can use testng soft assertion method.

Browser compatibility software testing Is most Important thing for any software web application and generally you have to perform browser compatibility testing before 1 or 2 days of final release of software web application. In such a sort time period, you have to verify each Important functionality In every browsers suggested by client. If you will go for running your all webdriver tests In each browsers one by one then It will take too much time to complete your software tests and you may not complete It before release. In such situation, Running your tests In all required browsers at same time will helps you to save your time efforts. So question Is - Can we run our tests parallel In all required browsers using webdriver software automation testing tool? Answer Is yes.

If you remember, I have posted many posts on TestNG Framework and you will find all those posts on THIS LINK or you can VIEW THIS PAGE for all related posts listing. Study all of them one by one on posted date order for your better understanding. Till now we have learnt about how to Include or exclude TEST METHOD, PACKAGE from execution. We have also learnt REGULAR EXPRESSION USAGE for Including or Excluding Test methods from execution. Now supposing you wants to skip specific test Intentionally from execution then how can you do It?

As you know, there are many assertions in TestNG and you will find most of them on THIS PAGE. Each of these TestNG assertions are designed to fulfill different kind of conditions. I have described mostly used all assertions with very clear examples with selenium webdriver test. If you will see on that link, you will find example of assertNull assertion. assertNotNull assertion works opposite to assertNull assertion means it will assert not null condition.

As you know, TestNG is the framework which is very useful to use with selenium WebDriver software testing tool. I have shared all selenium webdriver with testng tutorials on THIS LINK. The main reason behind TestNG's popularity is we can create and configure test case and test suite very easily for software web application using many different annotations of TestNG. Few annotations are similar in TestNG and junit and you can view junit annotations with example on this JUNIT ANNOTATIONS POST.

Assertions are very useful to check your expected result and skip execution if assertion fails on run time. If you are selenium IDE user, you can read all these selenium IDE ASSERTION COMMANDS examples posts to use them in your test cases for your web application. Before describing about assertNull assertion of testngI recommend you all to READ OTHER WEBDRIVER ASSERTION METHOD examples for your reference.

When you are working with selenium webdriver, you must be aware about different kind of assertions which are available. If you have a enough knowledge about testng assertions, You can create very effective test cases for your test scenarios. assertEquals, assertNotEquals and assertTrue assertions are already explained in my previous posts. Now let we try to understand usage of testng assertfalse in selenium webdriver.

Previously we have learnt two assertions of selenium webdriver software testing tool. You can view practical example pages of selenium webdriver assertionsassertEquals and assertNotEquals before learning asserttrue in selenium. There is also one another related assertion is assertFalse(condition) assertion but we will look about it in my next post.

As described in my previous post, assertEquals assertion is useful to compare two string, boolean, byte[], char, double, float, int, etc.. and based on assertion result,  Your test method will pass or fail. This pass or fail indication will helps you in your testing process. So this is the very good function in selenium WebDriver which helps us to find and log issue. Please note one thing once more is - Use hard assertions in selenium webdriver only when you wants to skip remaining test execution on assertion fail. If you wants to continue execution on assertion failure, you can use TestNg soft assertions. We will discuss about it in my upcoming post.

There are many assertions available in Selenium WebDriver software testing tool with TestNG framework and we will look at all of then one by one. Assertions are important and very useful in any software automation tools to assert something during your test execution. If you know, Selenium IDE software testing tool has many built in assertion commands and if you are selenium IDE user then you can view set of selenium IDE assertion command examples on THIS LINK.

It is very important for us to know the each and every way of testng.xml configuration to include/exclude selected test methods or packages in execution. You can view my posts to know how to include/exclude SELECTED PACKAGE or SELECTED TEST METHODS from selenium webdriver test suite execution. There is also one another way of including or excluding selected test method using regular expression. Let me describe it with one simple example.

Now you are already aware about HOW TO INCLUDE OR EXCLUDE SELECTED TEST METHODS IN TEST SUITE. Now our next tutorial is about how to include or exclude selected package from execution of test suite. Supposing you have multiple packages in your webdriver test suite and you wants to run only specific selected package then how will you do it? Let we look at simple example for the same.

If you are using selenium webdriver with TestNg framework then you can easily run your selected test methods from selected classes. Supposing you have a two classes in your package and first class have three test methods and second class have five test methods. Now you wants to run only one test method from first class and two test methods from second class then you can configure it very easily in testng.xml file. In sort, you can include or exclude selected test methods from execution. Let me show you how to do it with simple webdriver test configured by testng.xml file.

TestNG is very useful and powerful framework for selenium webdriver. We need to configure our tests based on our requirements or test scenarios. We are going very slowly with TestNG framework to understand each and everything clearly with examples so that it can help you to configure your test in any king of situations. In my previous posts, we have learnt about HOW TO RUN SPECIFIC CLASS FROM DIFFERENT PACKAGE USING testng.xml and HOW TO RUN SINGLE OR MULTIPLE CLASSES FROM ONE PACKAGE USING testng.xml. So now you can configure your testng.xml file to run any specific class from any package if you have read both previous posts.

Now you are already aware about HOW TO CREATE testng.xml FILE to configure and run your webdriver test. The main reason behind popularity of TestNG framework for webdriver is we can configure our test as per our requirements. I have listed some Similarities/Differences between Junit and TestNG framework In THIS POST. In my previous post, We have already seen example of how to configure testng.xml file to run single/multiple webdriver test classes of same package. Now let me show you an example of how to create test suite using classes from different packages.

As i have described in my previous post, We can configure our webdriver test or webdriver test suits for software testing project in testng.xml file. In my previous post, we have seen how to create testng.xml file to run single test class for software web application. Also If you don't know how to create and run first TestNG-WebDriver test, You can VIEW THIS POSTNow supposing you have two/multiple classes in your test suite for software web application then how will you run them? We can run both the classes in same test as well in 2 different tests too for software web application.

Introduction Of testng.xml File
In TestNG framework, We need to create testng.xml file to create and handle multiple test classes. testng.xml is the file where we can configure our webdriver software automation test, set software test dependency, include or exclude any software test method or class or package, set priority etc.. We will learn each and every thing about TestNG usage in my future posts. Right now let me describe you how to create testng.xml

Our next step to do is - TestNG software test case creation in eclipse after installation of TestNG in eclipse. You can VIEW TESTNG INSTALLATION STEPS in my earlier post if you have not configured TestNG in your eclipse. Now let me describe you steps of writing your first selenium webdriver software automation test case with TestNG.