Skip to content

Tizen.Appium is a service library that supports running Appium for Tizen applications.

License

Notifications You must be signed in to change notification settings

flyofsky/Tizen.Appium

 
 

Repository files navigation

Tizen.Appium NuGet NuGet

Tizen.Appium is a service library that supports running Appium for Tizen .NET applications. It can simulate user interactions on Tizen .NET applications (ElmSharp,NUI) and also cross platform Xamarin.Forms application. As its name implies, it works based on the Appium that is an open source test automation framework.

Getting Started with Tizen.Appium

Tizen.Appium allows developers to write automated UI tests for Tizen .NET.

Prepare Your Test Environment

This link show how to setup the Appium.

Adding Tizen.Appium support to Tizen .NET apps

To automated your Tizen .NET applications, add Tizen.Appium as a pacakage referernce to your application project.

<PackageReference Include="Tizen.Appium" Version="1.0.0-preview" />

ElmSharp and NUI applications require a Tizen.NET package version 6.0 or higher.

Xamarin.Forms application requires a Tizen.NET 4.0.0.

Initializing the Tizen.Appium

Add the following code to initialize Tizen.Appium.

ElmSharp Application

using Tizen.Appium;

class App : CoreUIApplication
{
    protected override void OnCreate()
    {
        base.OnCreate();
#if UITEST
        TizenAppium.StartService(AppType.ElmSharp);
#endif
        //...
     }
     //...
}

NUI Application

using Tizen.Appium;

class Program : NUIApplication
{
    protected override void OnCreate()
    {
        base.OnCreate();
#if UITEST
        TizenAppium.StartService(AppType.NUI);
#endif
        //...
    }
    //...
}

Xamarin.Forms Application

using Tizen.Appium;

class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
{
    protected override void OnCreate()
    {
        base.OnCreate();
#if UITEST
        TizenAppium.StartService();
#endif
        LoadApplication(new App());
        //...
    }
    //...
}

Set AutomationId in Test Application

Tizen.Appium automates the user interface by activating controls on the screen and performing input. To do this, you should assign a unique identifier to each controls.

Note that an exception will be thrown if an attempt is made to set the AutomationId property more than once.

ElmSharp Application

In ElmSharp, the recommended way to set this identifier is by using AutomationId property as shown below.

var button = new Button(window)
{
    Text = "button",
    AutomationId = "button"
};

NUI Application

The true is same on NUI application.

PushButton button = new PushButton
{
    LabelText = "Button",
    AutomationId = "button"
}

Xamarin.Forms Application

The true is same on Xamarin.Forms application.

Button button = new Button
{
    Text = "Button",
    AutomationId = "button"
}

Writing Your Test Script

Visual Studio has a template to help add a Tizen .NET UI Test projenct to an existing your application solution:

Upcoming Visual Studio Tools for Tizen will support this template. Until then, you can manually create and use the UI test project.

  1. Right click on the solution, and select File > New Project

  2. From the Tizen Templates, select the UI Test App template

How to manually create a UI Test project

  1. Create a test project in Visual Studio
    Select Visual C# -> Test -> Nunit Test Project

    If you know use to other test project, you can use it.

    image

  2. Add Appium.WebDriver as a package reference to your project (*.csporj)

Tizen driver is supported from Appium.WebDriver 4.0.0.2-beta. Therefore, we recommend that you use the version or later.

  1. Add the following code to initialize the TizenDriver and set the AppiumOptions
public class UITest
{
    TizenDriver<TizenElement> _driver;

    [SetUp]
    public void Setup()
    {
        AppiumOptions appiumOptions = new AppiumOptions();

        appiumOptions.AddAdditionalCapability("platformName", "Tizen");
        appiumOptions.AddAdditionalCapability("deviceName", "emulator-26101");

        //Xamarin.Forms
        appiumOptions.AddAdditionalCapability("appPackage", "org.tizen.example.FormsApp.Tizen.Mobile");

        //ElmSharp
        //appiumOptions.AddAdditionalCapability("appPackage", "org.tizen.example.ElmSharpApp");

        //NUI
        //appiumOptions.AddAdditionalCapability("appPackage", "org.tizen.example.NUIApp");

        _driver = new TizenDriver<TizenElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
    }

    [Test]
    public void Test1()
    {
        _driver.FindElementByAccessibilityId("Button").Click();
    }
}

Write scripts with reference to Supported Commands

Make sure you set the appium server ip(ex:127.0.0.1:4723) and port number. You should set same server port number. (appium default port number is '4723')

If you want to find a device name, use 'sdb devices' command. You can find device list and the name.

  1. Install Nunit3 Test Adapter
    Go to Tools -> Extesion and Updates -> Select Online -> Search 'Nunit 3 Test Adapter' image

  2. Open Test Explorer
    Go to Test -> Windows -> Test Explorer
    image

Running UI Automation Test

Right-click on your test, and select ‘Run Test’.
image

If the test is successful.
image

If the test is fails, you can determine the cause.
image

Current Support

Wearable

  • 4.0 or later version of Wearable devices and Emulator.

Mobile

  • 4.0 or later version of Emulator.

TV

  • Not Supported due to security policy at the moment.

About

Tizen.Appium is a service library that supports running Appium for Tizen applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%