0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windows Application Driverでsessionを作成時に発生するWindowsDriver<WindowsElement>の引数エラーを回避する方法

Last updated at Posted at 2020-07-25

#はじめに
WinAppDriverの公式GitHubでテストスクリプトの書き方が公開されていますが、公式通りに書いたら引数エラーが発生したので回避方法を書き留めます。

#公式ページ通りにテストスクリプトを書いてみる
参照

UnitTest1.cs
public void TestMethod1()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();
            appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");
            AlarmClockSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);

            AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click();
            AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();
        }

##new WindowsDriver<WindowsElement>の引数で下記エラーが発生
image.png

引数 1: は 'System.Uri' から 'OpenQA.Selenium.Appium.AppiumOptions' へ変換することはできません。
引数 2: は 'OpenQA.Selenium.Remote.DesiredCapabilities' から 'System.TimeSpan' へ変換することはできません。

解決方法

DesiredCapabilities を AppiumOptions で代替することができる。

修正後コード

UnitTest1.cs
public void TestMethod1()
        {
            // DesiredCapabilities appCapabilities = new DesiredCapabilities();
            AppiumOptions appCapabilities = new AppiumOptions();
            // appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");
            appCapabilities.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");
            AlarmClockSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);

            AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click();
            AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();
        }

参考
https://github.com/microsoft/WinAppDriver/issues/529#issuecomment-482426016

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?