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

    起動中のMicrosoft EdgeからタイトルとURLを取得するC#コード(DOM編)

    2017/8/18 追記:当記事のコードは現在動作しなくなっている…

  2. その他

    Photoshop CSのライセンス認証問題

    今更ながらに、10年ほど前に発売された「Photoshop CS」をイ…

  3. その他

    Google先生も薦めるからSSL証明書を取得してみました。

    「Google、検索結果ランキングでHTTPS対応サイトを優遇へ」とい…

  4. Windows 10

    [Windows 10]Microsoft Edgeでブックマークレットを使う。

    2017/3/29 追記:新しく記事を書き直しました。…

  5. Windows 10

    【2017年4月版】Microsoft Edgeで開いているページを名前を付けて保存する方法

    2015年8月に、Microsoft Edgeで開いているページを名前…

  6. Windows 10

    [Windows 10]Update Complianceで端末のアップデート管理を行う方法

    システム担当者にとって、高度・多様化するサイバー攻撃に対し、OSのアッ…

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP