dotnet-client icon indicating copy to clipboard operation
dotnet-client copied to clipboard

Generic mobile driver interface to use for single codebase android/iOS

Open szymon-kazmierczak opened this issue 4 years ago • 3 comments

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:

szymon-kazmierczak avatar Feb 03 '21 10:02 szymon-kazmierczak

I'm having the same issue exactly a year later. Did you ever resolve this?

kkauffman-incomm avatar Feb 03 '22 16:02 kkauffman-incomm

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);

soniiic avatar Apr 29 '22 09:04 soniiic

Sorry just seeing this now - yeah that's what i ended up doing, using AppiumDriver<AppiumWebElement>

szymon-kazmierczak avatar Apr 29 '22 09:04 szymon-kazmierczak

@szymon-kazmierczak so this issue can be closed?

Dor-bl avatar Nov 06 '22 19:11 Dor-bl