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





Join Telegram channel of this blog at https://t.me/techlisticspace
Feel free to ask queries or share your thoughts in comments or email me.

Comments

Post a Comment

Popular Posts

Top 10 Demo Websites to Practice Selenium Webdriver Online

Top 25 Must to know Selenium Webdriver Commands List

Selenium WebDriver - Take Screenshot and Partial Screenshot Commands

Selenium WebDriver - Browser and Navigation Commands

Selenium Essentials - How to become expert in Automation Testing?