Right now, We are learning some commonly used functions which can actually helps us to minimize our webdriver test case code size. As you know, You need to perform some actions (Example : Comparing Strings, Comparing Integers, Compare Double, And More Like This) many times during your test case execution so repeating same code In every test case Is not a good practice. You can create and common function In some common class and then call that function whenever required.

Whenever you start your any webdriver test, First of all you need to start your browser. And at the end of your test, You need to close your browser. Now supposing you have 100s of test cases then you will write browser opening and closing code In each and every test? Or supposing you wants to run all your tests In Google chrome browser Instead of Mozilla Firefox browser then you will go to change code In your each and every test cases?

Comparison of double values Is not much more different than comparison of Integer values as described In my previous post but let me give you example of same so that you can get It better. Let me tell you one thing that comparison of different data types (compare two strings, compare two Integers, etc..) Is pure java concept and It has not any relation with selenium webdriver. My main Intention Is to show you that how to handle rest of test execution based on execution result and how to mark your test fail In webdriver test report without any Interruption In execution.

We have learnt how to create common function to compare two strings In my previous post. Same way, Many times you need to compare two Integer values. And based on comparison result, You can perform your next step of test execution. You can also stop or continue your test execution on assertion failure by using soft or hard assertions of TestNG . In this post, we will see how to compare two Integer values using common function.

When you will use selenium webdriver to automate real world applications, Many times you have to compare two strings like page title, product name or any other string. And based on comparison result you have to take specific action. Simple example of such scenario Is, You are navigating on any view product page to add product In to basket. But before adding product In basket, You wants to verify product's name to check It Is correct product or not.

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.

If web table has same number of rows and same number of cells In each rows every time you load page then It Is very easy to handle that table's data In selenium WebDriver software testing tool as described In How To Extract Table Data/Read Table Data Using Selenium WebDriver post. Now supposing your table's rows and columns are increasing/decreasing every time you loading page of software web application or some rows has more cells and some rows has less cells then you need to put some extra code In your webdriver software test case which can retrieve cell data based on number of cells In specific row. Consider the dynamic webtable shown In bellow given Image.