Windows 10

Windows Application Driverを試してみました。

Build 2016のセッション「UI Test Automation for Browsers and Apps Using the WebDriver Standard」でWindows Application Driver(WinAppDriver)が紹介されていたので、さっそく試してみました。

下準備

  1. Windows Application Driverをダウンロード・インストールします。
  2. NuGetから「Appium Webdriver」をインストールします。
  3. nuget install "Appium.WebDriver"

電卓を操作するC#コード

//appium-dotnet-driver.dll, WebDriver.dll 要参照
using System;
using OpenQA.Selenium.Remote;

namespace AppiumSample
{
  class Program
  {
    public static void Main(string[] args)
    {
      //Windows Application Driver実行
      string serverPath = System.IO.Path.Combine(
        System.Environment.GetFolderPath(
          System.Environment.SpecialFolder.ProgramFilesX86
        ), @"Windows Application Driver", "WinAppDriver.exe"
      );
      System.Diagnostics.Process.Start(serverPath);
      
      //電卓操作
      DesiredCapabilities appCapabilities = new DesiredCapabilities();
      appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
      RemoteWebDriver driver = new RemoteWebDriver(new Uri(@"http://127.0.0.1:4723"), appCapabilities);
      driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
      driver.FindElementByName("1").Click();
      driver.FindElementByName("2").Click();
      driver.FindElementByName("3").Click();
      driver.FindElementByName("4").Click();
      driver.FindElementByName("5").Click();
      //driver.Dispose();
      //driver = null;
      
      Console.Write("Press any key to continue . . . ");
      Console.ReadKey(true);
    }
  }
}

Windows_Application_Driver_01

コードを見れば分かる通り、Selenium WebDriverと同じような書き方でテストコードを書くことができます。

・・・が、Beta版だけあってまだまだ動作は不安定。
現時点では「Winium.Cruciatus」の方が完成度は高いように感じます。

とはいえ、“Microsoft公式”という信頼感、そして今後の予定としてはモバイルやXboxまでサポートしていくらしいので、共通のコードでWin32アプリからUWPアプリ、果てはXboxアプリまでテストできるとなると、かなりの強みになるだろうと思います。

2016年3月の人気記事前のページ

Microsoft Edgeの拡張機能を使って短縮URLを取得してみる。次のページ

関連記事

  1. その他

    HTML5の構文チェックを行う「Validator.nu (X)HTML5 Validator」のW…

    HTML5の構文チェックをしてくれる「Validator.nu (X)…

  2. Office アドイン

    Live Serverとmkcertで簡単にローカルhttpsサーバーを立ち上げる方法

    Office アドインのテストを行うのに、簡単に構築できるhttpsサ…

  3. Office関連

    覚えていますか?ISHとLHA、パソコン通信の思い出

    この記事のアイキャッチ画像、文字化けしているわけではないですよ。画…

  4. Windows関連

    Windows 8 Release PreviewにClassic Shellをインストールしてみま…

    2012/8/22 追記:Windows 8 RTMにインストール…

コメント

  • コメント (0)

  • トラックバックは利用できません。

  1. この記事へのコメントはありません。

Time limit is exhausted. Please reload CAPTCHA.

※本ページはプロモーションが含まれています。

Translate

最近の記事

アーカイブ

PAGE TOP