Selenium-TestNG: Set Dependency Among Test Methods

TestNG provides a way to manage method dependencies with annotation parameters. For this testNg provides 'DependsOnMethods' parameter for @Test annotation. If you have declared dependency of one method on second, then first of all second method will be executed and then after first method. 
Below is the code snippet:



In above code, method SignIn() is dependent on OpenBrowser() and method LogOut() is dependent on SingIn and OpenBrowser methods. 

Below is the execution sequence of above code snippet:
1. OpenBrowser
2. SignIn
3. LogOut.

Output:
This will execute first (Open Browser)
This will execute second (SignIn)
This will execute third (Log Out)


Selenium-TestNG Integration  << Previous    ||    Next >>  Set Priority inTestNG


Follow Us

Quora Space | Facebook Page | Telegram Channel
Feel free to ask queries or share your thoughts in comments or email us.

Comments

Popular posts from this blog

10 Best Demo Websites for Automation Testing Practice

Automate 'User Registration' of E-commerce Website using Selenium

Selenium WebDriver Browser and Navigation Commands

Automate 'Buy Product' from E-commerce Website using Selenium