Sunday, August 27, 2017

How to prioritize test cases from different test sets (java classes) in TestNG?

In the previous post we have seen the importance of priority and how to use it in TestNG in one test set, here a test set is nothing but a java class that contains one or more test cases (@test methods). Now we will learn prioritizing the test cases that are present in different test sets.
As show in the below screenshot we have one regression test and one smoke test. And each test contains two test sets.

Saturday, August 26, 2017

What is priority in TestNG and How to use it ?

Priority is an attribute used along with @Test annotation to set the priority of a test case. Using priority user can define the order of the execution of test cases (@Test methods) in a java class. Some points on priority in TestNG are below:
  • The default priority of any test case (@Test method) is zero. That is highest priority.
  • Higher the priority value, lower is the priority. In test set (java class) @Test (priority=0) highest priority, @Test (priority=1) second priority, @test (priority=2) third priority and so on.
  • If no priority is defined, all the test cases are having zero priority. In this case the test cases will be executed in alphabetical order.
Real Time Scenario: There could be situations where we need to execute the test cases in a sequence to achieve a task, suppose I have a scenario sending an email. To do this task the sequence of test execution will be 1) launching application, 2) login to account, 3) compose email and send, finally 4) logout.  So here prioritizing the test cases is required. Let us do this…

Friday, August 25, 2017

How to execute multiple test cases in TestNG?

There are different ways to execute the multiple test cases in TestNG using testng.xml file. As discussed in my previous post Importance of testng.xml testng.xml is used to define the test execution process. We can definethe test execution process based on requirement in testng.xml files. And we can have more than one testng.xml file (with different title) in your project. In this post we will discuss about different ways to execute the multiple test cases.

Assume we have a TestNG project with regression tests (“regressionTests”) and smoke tests (“smokeTests”). And regressionTests contains two sets of test cases regressionSet1 and regressionSet2. Similarly smokeTests contains smokeSet1 and smokeSet2. Each test set contains three test cases (@test methods). Please find the screen shot below.

Tuesday, August 15, 2017

How to take screenshot of WebElemets in Selenium?

In the previous post AShot() in Selenium 3 for taking full page screenshot? we have seen how to capture the full page screenshot in Selenium using AShot() utility. Now we will see how to capture the screenshot of WebElement using AShot().

Syntax: The below method is used to capture the screenshot of the web element.
  • We need to pass two arguments to the above method, one is WebDriver object and another is web element . 
aShot will find element's size and position and crop original image. WebDriver API provides a method to find the WebElement's coordinates  but different WebDriver implementations behave differently.

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...