https://github.com/vikashchauhan51/appiumcore
test cross platform mobile application with Appium C#
https://github.com/vikashchauhan51/appiumcore
appium appium-android appium-ios cross-platform cross-platform-testing csharp mobile
Last synced: about 1 year ago
JSON representation
test cross platform mobile application with Appium C#
- Host: GitHub
- URL: https://github.com/vikashchauhan51/appiumcore
- Owner: VikashChauhan51
- License: mit
- Created: 2020-11-04T09:53:23.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-25T03:46:36.000Z (over 1 year ago)
- Last Synced: 2025-04-12T00:13:12.138Z (about 1 year ago)
- Topics: appium, appium-android, appium-ios, cross-platform, cross-platform-testing, csharp, mobile
- Language: C#
- Homepage:
- Size: 68.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AppiumCore


This is a [Appium](https://appium.io/docs/en/latest/) client wrapper to test cross platform mobile application with same code base using C#.
[](https://www.nuget.org/packages/AppiumCore/)
[](https://www.nuget.org/packages/AppiumCore/)
[](https://github.com/VikashChauhan51/AppiumCore/actions)
[](https://github.com/VikashChauhan51/AppiumCore/blob/main/LICENSE)
## Installation
You can install the AppiumCore package via NuGet:
```shell
dotnet add package AppiumCore
```
Or you can use the NuGet Package Manager:
```shell
Install-Package AppiumCore
```
## Quick Start Example (Nunit Framework):
```C#
using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Service;
using AppiumCore;
[TestFixture(Platform.iOS)]
[TestFixture(Platform.Android)]
public class AppSetupTest
{
private readonly IApp app;
public AppSetupTest(Platform platform)
{
switch (platform)
{
case Platform.Android:
// update `AppiumOptions` and `AppiumLocalService` as per you requirment.
app = ConfigureApp.Android.StartApp(new AppiumOptions(), AppiumLocalService.BuildDefaultService());
break;
case Platform.iOS:
// update `AppiumOptions` and `AppiumLocalService` as per you requirment.
app = ConfigureApp.iOS.StartApp(new AppiumOptions(), AppiumLocalService.BuildDefaultService());
break;
default:
break;
}
}
[Test]
public void SampleTest()
{
app.FindElement(By.Id("app")).Click();
Assert.Pass();
}
}
```
*Here `SampleTest()` will execute on both `iOS` and `Android`, and `app.FindElement(By.Id("app")).Click()` will internally switch to the respective driver as we configured at startup.*
This will reduce your codebase size and maintenance cost. 😊
We have three interfaces: `IApp`, `IAndroidApp`, and `IIOSApp`. The `IApp` interface provides common APIs available in the Appium driver for both platforms, and the platform-specific interfaces provide complete platform-specific APIs available in the respective platform-specific drivers.
Please use `AppiumLocalService` at startup if your mobile app is hybrid, where the application redirects to a web browser for functionalities like signup/sign-in. In this case, the app will switch from Native view to Web view. We have also added an additional APIs(`SwitchToWebView()` and `SwitchToNativeApp()`) to handle this in your script before calling any action method of the APIs. For documentation, please refer to their official documentation, as linked below.
## Reference
- Inspired from [Xamarin.UITest](https://learn.microsoft.com/en-us/appcenter/test-cloud/frameworks/uitest/).
- [Appium Dotnet](https://appium.io/docs/en/latest/quickstart/test-dotnet/).