dotnet-client
dotnet-client copied to clipboard
Generic mobile driver interface to use for single codebase android/iOS
Description
I'm confused by the use of generics and interfaces in Appium DotNet driver.
I'm trying to keep my appium driver instance generic enough so that i can have both iOS and Android in the single codebase. This doesn't seem possible in Appium Dot net driver, as you require concrete implementation from the get go.
For example, neither of the following will work in the follow up code:
public AppiumDriver driver;
public AppiumDriver<IMobileElement<IWebElement>> driver;
if(TestPlatform == Platform.Android)
driver = new AndroidDriver<AndroidElement>(serverUri, capabilities, Env.InitTimeoutSec);
else if (TestPlatform == Platform.iOS)
driver = new IOSDriver<IOSElement>(serverUri, capabilities, Env.InitTimeoutSec);
Environment
- .NET client build version or git revision if you use some shapshot: 4.3.1
- Appium server version or git revision if you use some shapshot: 12.0.0
- Desktop OS/version used to run Appium if necessary:
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe:
- Mobile platform/version under test: iOS, Android
- Real device or emulator/simulator:
I'm having the same issue exactly a year later. Did you ever resolve this?
Using AppiumWebElement
as the generic type is as close as you're going to get.
public AppiumDriver<AppiumWebElement> driver;
if(TestPlatform == Platform.Android)
driver = new AndroidDriver<AppiumWebElement>(serverUri, capabilities, Env.InitTimeoutSec);
else if (TestPlatform == Platform.iOS)
driver = new IOSDriver<AppiumWebElement>(serverUri, capabilities, Env.InitTimeoutSec);
Sorry just seeing this now - yeah that's what i ended up doing, using AppiumDriver<AppiumWebElement>
@szymon-kazmierczak so this issue can be closed?