How to preserve Appium session between multiple testng class

后端 未结 3 1422
北荒
北荒 2021-01-03 16:18

I am automating Android application using Appium, I have One Base Class with Setup and Tear down (In setup initialization appium session and in teardown destroying session )

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-03 17:12

    You can achieve the same without inheriting base class.

    Step1 -> Initialize driver object in your set up i.e your setup method as driver=new AndroidDriver(url,caps);

    Step 2-> If you have any Utility or Constant class, call its constructor and pass driver as a parameter e.g. new Constants(driver);
    Note: You can mark driver as a static variable if you only need one driver instance.

    Step 3-> Whenever you wish to access driver, access it as Constant.driver or initialize driver object at class level.

提交回复
热议问题