Even though the CloseBrowser method was declared first, AccountTest was the one that ran before CloseBrowser. The OpenBrowser ran first, no questions there!! But, an interesting pattern appears in the methods containing similar priorities ( 1). In the above code, I have set the priority of AccountTest and CloseBrowser as one while OpenBrowser retains its priority of 0. ( "Launching Google Chrome (priority = 1) If priority is deciding the sequence of tests in TestNG, then a simple question arises in our minds: what if I declare the same priority to all the tests in TestNG? Let' see this case by observing the following code: import Had I not declared the priority here, it would have run alphabetically, i.e., CloseBrowser first and then OpenBrowser. The priorities set are 0 for OpenBrowser and 1 for CloseBrowser, so I expect the OpenBrowser method to run first.Įxecute the above TestNG test file to check the output.Īs expected, the OpenBrowser method ran first because of a lower priority. In the OpenBrowser method, I am trying to open the browser and enter the URL "The " CloseBrowser" method, however, is used to close the driver. Observe the following code, which has two methods: OpenBrowser and CloseBrowser. Writing a test case with priority in TestNG is similar to how we write a typical test case in TestNG but with a " priority" attribute. How To Run Prioritized Tests In TestNG Using Selenium? Keeping these points in mind, we are ready to run our first test with declared priority methods using selenium. Priority cannot pass through the XML files.One method is allowed to have only one priority in TestNG.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |