jeudi 2 avril 2020

PYTHON: How to start each test with different capabilities?

I am writing tests for a mobile app, where the first screen is a Login screen. I do have that covered but in other tests I want to skip test_Login and go straight to test_DoStuffOnHomeScreen

What would be the best approach? I am using

def get_desired_caps(application):
    return dict(platformName='Android', deviceName="$DEVICE",
                application=PATH('../apps/' + app), appPackage='xxx',
                appActivity='xxx.MainActivity', newCommandTimeout=240, noReset='true', fullReset='false')

as my desired capabilities - when I run this without noReset and fullReset it's taking me to login screen, which is fine. But what about other scenarios? My starting session script looks like that

class StartSession(unittest.TestCase):

def setUp(self):
    desired_caps = desired_capabilities.get_desired_capabilities('xxx.apk')
    self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    self.application = Application(self.driver)

def tearDown(self):
    self.driver.quit()

Which is used then in tests:

class LoginPage(StartSession):

    def test_login_with_valid_credentials(self):

Aucun commentaire:

Enregistrer un commentaire