POM for C# code

I am just wondering if anyone working with C# and Appium have figured out a efficient way to incorporate POM in their code? From what I understand there is not an clean/easy way to do this in C# (like you can do in Java using decorators for Android and iOS FindBy methods).
Currently I have 2 folders, one for Android and one for iOS with a set of Classes/Page Objects in each one (Login class for iOS using IOSDriver and iOS locators, Login class for Android using Android Driver and Android locators etc…) It’s not pretty but it works.

The one idea I had was to combine them into one Login class, initiate both drivers, list all locators for both and then use a bunch if if/else statements in the methods. I don’t think that is really any better though than what I am currently doing.

With C# specifically does anyone know of a better approach?

One thing we do in our code is to utilize the settings to determine the OS of the device under test, so, for example if “platformName”: “iOS” is in capabilities, then we instantiate the iOS Driver and move on with the tests. There is a certain elegance to this approach.

Having said that, there are some good tutorials on C# POM with Selenium, and I think a lot of those concepts can be easily used in Appium. Here is one:

Good luck!

1 Like