Appium .NET Client

repository·main·Indexed 19 days ago

https://github.com/appium/dotnet-client

An extension of the Selenium C# client that provides Appium-specific methods for mobile application automation within the .NET ecosystem. It depends on Selenium.WebDriver and System.Drawing.Common, and is available via the Appium.WebDriver NuGet package.

Tokens
1.2K
Snippets
4
Records
7
Agent score
14%

What's inside appium-dotnet-client

  1. Migrate from deprecated methods to extension commands (v8)

    main

    In v8, many deprecated endpoint method calls were replaced with compatible extension commands to maintain compatibility with Appium v3. If your driver does not yet implement these extension commands, you must update your Appium driver versions first.

    Removed Methods and their replacements:

    • ToggleAirplaneMode(), ToggleData(), ToggleWifi(), SetConnectionType() $\rightarrow$ Use mobile:setConnectivity with appropriate parameters.
    • GetConnectionType() $\rightarrow$ Use mobile:getConnectivity.
    • StartActivityWithIntent(), StartActivity() $\rightarrow$ Use mobile:startActivity.
    • EndTestCoverage() $\rightarrow$ Already deprecated.
    • HideKeyboard(strategy) $\rightarrow$ The strategy argument was removed (previously used by the outdated iOS driver).
  2. Install the Appium .NET Client via NuGet

    main

    The Appium .NET Client is an extension of the Selenium C# client. You can install it via NuGet. It depends on Selenium.WebDriver and System.Drawing.Common.

    To ensure deterministic builds, it is recommended to pin the Selenium.WebDriver version in your project, as the Appium client's behavior can be affected by Selenium updates.

    dotnet add package Appium.WebDriver
  3. Basic usage of Appium .NET Client

    main

    To use the Appium .NET Client:

    1. Add the namespace: using OpenQA.Selenium.Appium;.
    2. Construct the driver using the AppiumDriver class or one of its subclasses.

    Note that AppiumDriver works similarly to the Selenium WebDriver, but ports default to Appium values, and the driver does not start the Appium server independently. To use Appium-specific methods on an element, ensure you are using the correct AppiumDriver subclass or specify the parameters of the driver.

    using OpenQA.Selenium.Appium;
  4. Migrate to Appium 2.x and handle base-path changes

    main

    If you are using the v5.x client, you must either upgrade your Appium server to 2.x or add the --base-path argument to your server startup to maintain compatibility with the default server base path change:

    appium --base-path=/wd/hub

    Upgrading to Appium 2.x is highly recommended as Appium 1.x is no longer maintained.

    appium --base-path=/wd/hub
  5. Run Windows Applications with Appium .NET Client

    main

    Because WinAppDriver (WAD) has been abandoned by Microsoft, running Appium .NET Client 5.x with WAD will not work as it lacks W3C protocol support.

    To run Windows Applications, you must use appium-windows-driver, which acts as a proxy to WAD.

  6. Use W3C Actions for touch interactions

    main

    When using the v5.x client, you should use W3C Actions for touch and pointer interactions. This involves creating a PointerInputDevice, building an ActionSequence, and performing the actions via the driver.

    using OpenQA.Selenium.Interactions;
    
    var touch = new PointerInputDevice(PointerKind.Touch, "finger");
    var sequence = new ActionSequence(touch);
    var move = touch.CreatePointerMove(elementToTouch, elementToTouch.Location.X, elementToTouch.Location.Y, TimeSpan.FromSeconds(1));
    var actionPress = touch.CreatePointerDown(MouseButton.Touch);
    var pause = touch.CreatePause(TimeSpan.FromMilliseconds(250));
    var actionRelease = touch.CreatePointerUp(MouseButton.Touch);
    
    sequence.AddAction(move);
    sequence.AddAction(actionPress);
    sequence.AddAction(pause);
    sequence.AddAction(actionRelease);
    
    var actions_seq = new List<ActionSequence>
    {
        sequence
    };
    
    _driver.PerformActions(actions_seq);
  7. Check compatibility between Appium .NET Client and Selenium

    main

    The Appium .NET Client depends on specific versions of the Selenium .NET binding. Use the following matrix to ensure compatibility:

    Appium .NET ClientSelenium Binding.NET Version
    8.3.24.46.0.NET Standard 2.0
    8.3.04.44.0.NET Standard 2.0
    8.2.04.36.0.NET Standard 2.0
    7.2.04.29.0.NET Standard 2.0
    7.1.04.28.0.NET Standard 2.0
    7.0.04.27.0.NET Standard 2.0
    6.0.14.26.1.NET Standard 2.0
    6.0.04.25.0.NET Standard 2.0
    5.2.04.24.0.NET 6.0, .NET Framework 4.8
    5.1.04.23.0.NET 6.0, .NET Framework 4.8
    5.0.04.0.0 - 4.22.0.NET 6.0, .NET Framework 4.8