microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

AlarmClockTestAlarmClockTest does NOT work #1331

Open MikimotoH opened 4 years ago

MikimotoH commented 4 years ago

I git clone microsoft/WinAppDriver, and then open WinAppDriver/Samples/C#/AlarmClockTestAlarmClockTest.sln; I got this error in this line:

session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'System.Uri' to 'OpenQA.Selenium.Appium.AppiumOptions' AlarmClockTest C:\work\WinAppDriver\Samples\C#\AlarmClockTest\AlarmClockSession.cs 53 Active

My Nuget Packages and versions are:

WinAppDriver git version is a6f3d7b.

MikimotoH commented 4 years ago

After I modified DesiredCapabilities to AppiumOptions, then there is no compile error.

                var appOpts = new OpenQA.Selenium.Appium.AppiumOptions();
                appOpts.AddAdditionalCapability("app", AlarmClockAppId);
                session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appOpts);

However, I encounter OpenQA.Selenium.WebDriverException during Debug All Tests. File : ScenarioAlarm.cs Line: 55

WindowsElement alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{NewAlarmName}\")]");

Exception Detail is:

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=An element could not be located on the page using the given search parameters.
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Appium.AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
   at OpenQA.Selenium.Appium.AppiumDriver`1.FindElementByXPath(String xpath)
   at AlarmClockTest.ScenarioAlarm.AlarmAdd() in C:\work\WinAppDriver\Samples\C#\AlarmClockTest\ScenarioAlarm.cs:line 55
anunay1 commented 4 years ago

In the file ScenarioAlarm.cs change line 123 to

// Navigate to Alarm tab session.FindElementByAccessibilityId("AlarmPivotItem").Click();