When I use XML, @Beforemethod is running frequently, I mean i have classname1.method1 and classname2.method2 my test is executing @before while running classname1.method1 and executing again while running classname2.method2 How should I overcome this?

Hi I am Using TestNG framework and When I use XML, @Beforemethod is running frequently,
I mean i have classname1.method1 and classname2.method2. (in my xml)
My test is executing @before  multiple times meaning, executes @before while running  classname1.method1 and executes again while running classname2.method2
How should I overcome this?
Please suggest ….

Aruna Train Asked on March 3, 2015 in Selenium WebDriver.
Add Comment
1 Answer(s)

Hi Aruna,

I am not able to completely get your question because of lack of code and the testng xml file. However, I think what you are looking at is @BeforeClass and @AfterClass methods not the @BeforeMethod and @AfterMethod methods.

Virender

Virender Singh Professor Answered on March 3, 2015.

Hi Virender,
Thanks for responding
I have tried several ways and finally I got the solution
I just used inheritence and removed @Beforemethod and @Aftermethod and simply had @Test annotations in all my classes and then executed my .xml

Regards,
Aruna

on March 3, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.