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. Windows 10

    Windows Insider Meetup in Japan 2019 東京に参加しました。

    Windows Insider向けのミートアップイベント「Window…

  2. その他

    【サイエンスZERO】P・スワイヤーアイ(マリアナスネイルフィッシュ)特集

    昨年JAMSTECとNHKの研究チームが、マリアナ海溝の水深8,178…

  3. Windows関連

    Acer ICONIATAB-W500P1にWindows 8 Developer Previewを…

    AcerのタブレットPC「ICONIATAB-W500P1」にWind…

  4. Windows 10

    [Windows 10]アップグレードせずにクリーンインストールしたらどうなるの?

    「Windows 10をクリーンインストールする。」で、MediaCr…

  5. Windows関連

    Windows 8 Consumer Previewをインストールしてみました。

    先日、ついにWindows 8 Consumer Previewがリリ…

  6. Windows 10

    Microsoft Edgeを起動してキー操作を送るWindows 10のバッチ

    ITproに「Windows 10のコマンドプロンプトを使い込む - …

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP