skip to Main Content

I’m trying to test a react native app with the following test suite and cases:

Test case files:

  • login.ts
  • doActionAfterLogin_A.ts

Test suite:
[login.ts, doActionAfterLogin_A.ts]

Problem:
For login.ts I want to set the desired capability appium:noReset = false because I want to test the flow of the fresh install. However, I want to test doActionAfterLogin_A.ts with appium:noReset = true because I don’t want to go through the whole fresh installation flow again.

The problem is that in between test cases in the suite, Appium will close the browser/driver and launch again with the same desired capabilities, which in this case appium:noReset will always be false. Is there a way to either:

  1. Stop the browser/driver from closing in between test cases
  2. Change the desired capabilites in between test cases
  3. Is the way I’m structuring my test cases wrong?

Further info: Using Appium, Webdriverio, Mocha, Typescript

Thank you!

2

Answers


  1. From my understanding, there is no way to change DesiredCapabilities in between an AppiumDriver session. But in your situation, I think it’s best to decouple your Appium setup from your .ts test scripts.

    • Create a projectCapabilities.ts to set the AppiumDriver and the Capabilities
    • Create a hook where you define your Setup and TearDown
    • Create a Mocha Test Suite with a Test Case of each .ts
    before(setup() {});
    it('Test Case Name', testcase1Login(){});
    it('Test Case Name', testcase2DoAfterLogin(){});
    after(teardown() {});
    
    Login or Signup to reply.
  2. I set the driver capability values via system/env variables. I have a range of default values to fallback on if no system/env variable is found. But if I need to change one of the capabilities for a certain test, I make sure to set the system/env variable first.

    Logic for each test would then be:

    1. Set system/env variable "noReset" to true or false depending on your test
    2. Create instance of driver with capability "noReset" to have value of "noReset" system/env variable
    3. Run test logic
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search