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. その他

    日経ソフトウエア バックナンバーDVD 創刊号~2017年を購入しました。

    久しぶりのブログ更新です。先月は仕事がかなり忙しく、また、月末に風邪を…

  2. Windows関連

    Acer ICONIATAB-W500P1にWindows 8 Developer Previewを…

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

  3. その他

    【3月のライオン】色紙ARTを買ってみたよ。

    3日に1回は行く近所のイオン。今日もいつものように食玩コーナーをブ…

  4. Windows関連

    [Windows 8.1]Classic Shellをインストールしてみました。

    ※ 下記はWindows 8.1 RTM(日本語版・64ビット)に基づ…

  5. Windows 10

    Microsoft Edgeを起動するVBScript

    前回の記事の関連ですが、下記コードのようにShellExecuteメソ…

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP