I use Appium with Java to automate tests for mobile applications. It is clear that when I want to write tests for Android I use AndroidDriver<MobileElement> driver = [..]
and for iOS I need to use IOSDriver<MobileElement> driver = [..]
though with this approach I'd need to write same tests twice for iOS and Android. Is there a way that I could choose type of Appium Driver dynamically based on i.e. some kind of variable to choose between AndroidDriver
and iOSDriver
? I tried:
if(platform == "Android"){
//returns AndroidDriver
AppiumDriver<MobileElement> driver = COMMON.startAndroid(name, id, platform, version);
} else {
//returns IOSDriver
AppiumDriver<MobileElement> driver = COMMON.startIOS(name, id, platform, version);
}
but below in Test Eclipse points out that with this approach driver
is not defined