How webdriver session could be reused between tests in the class in AWS Device Farm?

359 views Asked by At

My appium/python test suite has tests that all require application login first. GitHub examples only show how to setUp/tearDown web driver for each test in the suite. In my case it would be great to reuse existent webdriver session for all the tests.

However, setUpClass/tearDownClass methods are executed for each test method in the AWS Device Farm environment. My attempts to create webdriver as a class variable did not work in AWS Device Farm (although worked locally).

What would be the optimal way to set the webdriver session, login into the application, then run all tests in the suite reusing the same web driver session and just then logout from the app and exit webdriver?

1

There are 1 answers

2
NikofTime On BEST ANSWER

I work for the AWS Device Farm team. You are correct in your observation about setup and teardown classes from your tests running before and after every test.

Each test in device farm runs against a new instance of appium server/session. This helps us provide more granular reporting and test artifacts to the user.

We also go along the lines that the users tests are modular as defined by most testing frameworks. This means that there is no dependency among the tests.

One way, and not the best way, to achieve what you are looking for would be to have all the test methods get called in the sequence you like inside a central test case. This way you can login and do other things in that one test case. The drawback obviously is that if any one of those tests fails it will report the main test to fail and you will have to write the tests such that it is evident in the logs what part of the test failed.

Second way would be to have the login step before the tests that require it. This way your tests are also modular and do not depend on each other.

We are always open to feedback and I have noted this down as a feature request. Hope this helps.