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 10 May 2021 Update(21H1)をクリーンインストールしてみました。…

    下記記事にもあるように、5月18日(米国時間)にWindows 10 …

  2. Windows 10

    [Windows 10]Microsoft Edgeに検索プロバイダーを追加する方法

    Windows 10のEdgeでは、デフォルトの検索エンジン(検索プロ…

  3. その他

    Visual Studio Codeの使い方メモ

    ここではVisual Studio Code(Windows版)を使っ…

  4. その他

    Microsoft Download Centerのファイルがリンク切れを起こしているときは?

    以前ブログで「Microsoftのサポートページに載っているファイルが…

  5. Windows関連

    [Windows 8]アプリをアンインストールする。

    今回はWindows 8でストアからインストールしたアプリをアンインス…

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP