| || |
Maintaining SessionID across classes within Java
I'm using TestNG and Java and I'm having an issue with passing the 'Selenium Session' across multiple classes.
Basically I have a @factory, @dataprovider and a @test all in separate classes and goes factory > dataprovider > test which works fine once but when it goes back to the @factory for the second set of parameters it appears the selenium session id is lost, which currently leaves me the only option of closing the session and re-opening the browser.
Anyone had any experience of multiple tests within the same browser session?
Re: Maintaining SessionID across classes within Java
basically you need to develop a framework where you can properly organize your test scripts.
As you mentioned that you have used test in all your classes that's why you need to maintain a session for every test.
If you want to use same session across the test suite so you can structure your test suite means keep only one test in you suite where you initialize your selenium object and pass it through the other classes as parameter , then you can achieve a proper OOPS and structured approach for you test suite.