Shared AppiumDriver in iOS & Android tests

Hello together,
im trying to merge my Android/iOS Test into one testsuite, so that i can use one test for both platforms using PageFactorys.

I currently facing a problem with instancing the driver.
In my “old” testsuites i use the specific driver (IOSdriver and AndroidDriver) for the tests.

Now i try to use the AppiumDriver and make that public so that all methods can use it.

My problem is now that i use functions like “getSystemBars” which seems not to exist in appiumDriver.

Does anyone has an example how i can get this running.

public static AppiumDriver driver;
if(getPlatform().equals("Android)) {
                driver = new AndroidDriver(new URL("http://127.0.0.1:4727/"), options);
}
if(getPlatform().equals("iOS)) {
                driver = new IOSDriver(new URL("http://127.0.0.1:4727/"), options);
}
driver.getSystemBars();


((AndroidDriver) driver).getSystemBars();
// or
((HasAndroidDeviceDetails) driver).getSystemBars();
1 Like

Works, thank you very much !