WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Samples are outdated

Open paulovila opened this issue 5 years ago • 31 comments

In projects like NotepadTest.sln in master Commit 35a65923 and others the test are not discoverable in VS2017. When I try to update the MSTest.TestAdapter and the MSTest.TestFramework, to 1.4.0, the tests are discovered, but the PopupDilalogSaveFile doesn't pass because in windows 10 the %TEMP%# doesn't get converted, probably because of the # ?. If I try to update it to the latest Selenium.Support and Selenium.WebDriver to version 3.141.0, it doesn't compile, because of the use ImplicitlyWait instead of ImplicitWait and some warnings come along, but it can be easily fixed.

In this case the test don't pass because: Message: Class Initialization method NotepadTest.ScenarioEditor.ClassInitialize threw exception. System.TypeLoadException: System.TypeLoadException: Method 'Dispose' in type 'OpenQA.Selenium.Appium.Service.AppiumCommandExecutor' from assembly 'appium-dotnet-driver, Version=3.0.0.2, Culture=neutral, PublicKeyToken=null' does not have an implementation.

So if I use the Appium.WebDriver 4.0.0.4-beta then some compilation errors occur, Error CS1503 Argument 2: cannot convert from 'OpenQA.Selenium.Remote.DesiredCapabilities' to 'System.TimeSpan' NotepadTest C:\Repos\WinAppDriver\Samples\C#\NotepadTest\NotepadSession.cs 41 but they can be fixed

and the tests pass but the notepad windows continues and windows explorer shows errors in the search.

Is it possible that for you guys to align the Samples to a working version of the Appium.WebDriver? Regards

paulovila avatar Nov 27 '18 10:11 paulovila

Hi @paulovila,

The "#" isn't actually inside source itself - this could be a discrepancy with the varying keyboard layout (are you using a non-US based keyboard layout?).

As far as the samples, this is something we will have to revisit / update in the future.

hassanuz avatar Dec 06 '18 00:12 hassanuz

Hi @hassanuz thanks for the response, I'm using an Irish keyboard, I'll test it soon with a US Keyboard. Hope it is not a distant future to get the solution, dependencies and samples updated. :) 👍 Regards PV

paulovila avatar Dec 06 '18 00:12 paulovila

I figured out that you are not allowed to update the Selenium.Support and Selenium.WebDriver. -> Stay with version 3.8.0 Set the wait line to "session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);"

This solves currently the problems and the example run.

Athameon avatar Dec 07 '18 11:12 Athameon

So are we supposed to use Appium.WebDriver 4.0.0.4-beta then?

xied75 avatar Dec 12 '18 15:12 xied75

I am also struggling with the samples. I tried AlarmClockTest.

  • I tried as is of dec 11. It builds, but only 1 out of 4 tests succeeds.
  • I thought of updating the Nuget packages. I got the ImplicitWait problem, fixed that. Then all tests failed with a message about Dispose. And also DesiredCapabilities was marked obsolete. I rolled back.
  • I also tried changing the Selenium versions to 3.8. I fixed the ImplicitWait problem again. And again just 1 test passed.

I am trying to get started with WinAppDriver. This does not really help. I am disappointed that a fresh version of the repository poses these problems.

a-einstein avatar Dec 18 '18 20:12 a-einstein

Hi @a-einstein,

We're looking into updating our samples early Jan to account for the newer Appium changes and default app changes, so please stay tuned.

hassanuz avatar Dec 18 '18 23:12 hassanuz

I have tried some of the other C# samples. AlarmClockTest was the only one even to contact WinAppDriver.

I have also tried the difference between QualityTools.UnitTestFramework and TestPlatform.TestFramework. That brought me nothing.

I am completely lost. How I am I supposed to get anything working if even the samples don't?

Also the described relation of WinAppDriver to Appium is confusing. Whether it should be installed, or running, the versions of either of them. I concluded I only need WinAppDriver.

a-einstein avatar Dec 19 '18 16:12 a-einstein

I am getting somewhere in my own project.

This helped me for the Dispose problem. https://github.com/SeleniumHQ/selenium/issues/6248

I will update this with new findings.

a-einstein avatar Dec 19 '18 19:12 a-einstein

I updated all NuGet packages in the CalculatorTest sample, however, an exception is thrown when I run the unit test.

In addition, I found the DesiredCapabilities is deprecated, but I don't know how to replace it.

Class Initialization method CalculatorTest.ScenarioStandard.ClassInitialize threw exception. System.TypeLoadException: System.TypeLoadException: Method 'Dispose' in type 'OpenQA.Selenium.Appium.Service.AppiumCommandExecutor' from assembly 'appium-dotnet-driver, Version=3.0.0.2, Culture=neutral, PublicKeyToken=null' does not have an implementation..
   at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
   at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Appium.Windows.WindowsDriver`1..ctor(Uri remoteAddress, DesiredCapabilities desiredCapabilities)
   at CalculatorTest.CalculatorSession.Setup(TestContext context) in C:\Users\Dingp\source\github\WinAppDriver\Samples\C#\CalculatorTest\CalculatorSession.cs:line 42
   at CalculatorTest.ScenarioStandard.ClassInitialize(TestContext context) in C:\Users\Dingp\source\github\WinAppDriver\Samples\C#\CalculatorTest\ScenarioStandard.cs:line 94
  <package id="Appium.WebDriver" version="3.0.0.2" targetFramework="net45" />
  <package id="Castle.Core" version="4.3.1" targetFramework="net45" />
  <package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net45" />
  <package id="MSTest.TestFramework" version="1.4.0" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
  <package id="Selenium.Support" version="3.141.0" targetFramework="net45" />
  <package id="Selenium.WebDriver" version="3.141.0" targetFramework="net45" />

DingpingZhang avatar Jan 08 '19 11:01 DingpingZhang

@hassanuz It's now getting close to end January and I still get the same message that DinpingZhang gets. What's the status of the updates?

essenius avatar Jan 23 '19 18:01 essenius

Hey guys....we would like to start using WinAppDriver for some browser dialogs automation, but I'm getting the same Dispose error as previously stated. It is now mid-March. Any updates on resolving compatibility?

okobets avatar Mar 08 '19 07:03 okobets

Hi @DingpingZhang, @essenius, @okobets,

We recently updated the samples - could you try using them with the default Nuget configuration?

hassanuz avatar Mar 12 '19 22:03 hassanuz

Hi Hassanuz, I am getting the same error on Calculator sample tests... CalculatorTest.ScenarioStandard.ClassInitialize threw exception. System.TypeLoadException: System.TypeLoadException: Method 'Dispose' in type 'OpenQA.Selenium.Appium.Service.AppiumCommandExecutor' from assembly 'appium-dotnet-driver, Version=3.0.0.2, Culture=neutral, PublicKeyToken=null' does not have an implementation.. Any idea how I can resolve this?

siteshahid avatar Apr 04 '19 11:04 siteshahid

Hey guys!

I'm solved the problem for me by using Appium.WebDriver 4.0.0.5-beta and modifying the source code of CalculatorSession.Setup method from:

DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CalculatorAppId); appCapabilities.SetCapability("deviceName", "WindowsPC"); session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);

to:

AppiumOptions opt = new AppiumOptions(); opt.AddAdditionalCapability("app", CalculatorAppId); opt.AddAdditionalCapability("deviceName", "WindowsPC"); session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt);

kope13 avatar Apr 12 '19 03:04 kope13

Thanks kope13,

I managed to do the same on the code and got it working .., I used AppiumOptions as well on Appium.WebDriver 4.0.0.5-beta and Selenium.Webdriver 3.141.0 and Selenium.Support to 3.141.0

siteshahid avatar Apr 12 '19 10:04 siteshahid

Thanks @kope13 this helped out big time.

One thing to note, it seemed that the WindowsDriver requires a type to be defined, so I modified the last line to:

new WindowsDriver<WindowsElement>(...)

So, the working snippet for me is now:

AppiumOptions opt = new AppiumOptions();
opt.AddAdditionalCapability("app", path);
opt.AddAdditionalCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt);

ben-burlingham avatar Jun 21 '19 18:06 ben-burlingham

We actually updated our samples when WinAppDriver v1.1.1 was introduced - so I'm trying to understand why there were / are not compiling for you guys.

For anyone running into issues with the latest samples on Master, please let us know which version of Windows you are using, and what exact error you are running into.

hassanuz avatar Aug 07 '19 03:08 hassanuz

I was getting the same error described in the OP. Rather than rolling back to Selenium 3.8 (as was suggested by some users), I used the solution offered by @kope13 and @ben-burlingham to solve the problem. The problem appears to be an incompatibility issue with newer Selenium drivers.

Appium.Webdriver 4.0.0.6 beta (my orig problem was with 3.0.0.2) Visual Studio 2017 (v15.9.14) Selenium 3.141.0 .NET Framework 4.6.1 Winver 1803

CreaturePrime avatar Aug 07 '19 12:08 CreaturePrime

Thanks for the info @CreaturePrime.

Most of our samples did switch over to the Microsoft.WinAppDriver.Appium.WebDriver nuget package (in lieu of Appium Webdriver), which should have solved most of the original issues being reported here - at the very least for notepad sample tests.

If the issues persist on the latest official Windows version (1903) then we'll look into updating our samples again. For now, I will close the opened PR.

hassanuz avatar Aug 16 '19 17:08 hassanuz

WinVer 1809

Notepad example:

Argument 1: Cannot convert from 'System.Uri' to 'OpenQA.Selenium.Appium.AppiumOptions'
Argument 2: Cannot convert from 'OpenQA.Selenium.Remote.DesiredCapabilities' to 'System.TimeSpan'

Happens when you install the Nuget package using the directions found in this doc: https://github.com/microsoft/WinAppDriver/blob/master/Docs/AuthoringTestScripts.md

Instead,

i. Tick the Include prerelease box ii. Install the Microsoft.WinappDriver.Appium.WebDriver NuGet packages for the test project

shogerr avatar Jan 09 '20 21:01 shogerr

The C# samples are still out of date. I'm was looking to provide a demonstration of winappdriver but the samples don't work. I have all Windows 10 updates to date installed. The latest apps aren't compatibility with the tests, providing a version number in each samples documentation would be helpful.

Initially I didn't update the nuget packages. After the tests failed I tried to update the nuget packages. With updated packages obsolete and deprecated features warnings appear in the build log.

AlarmClockTest

  • 1 test passed
  • 3 tests fail to find the "hours" text of newly scheduled alarms

CalculatorTest

  • All tests fail

NotepadTest

  • The tests passed
  • The last test makes a temporary file. The clean up didn't succeed in deleting the temp file. The automation missed typed the filename in the windows explorer search box. Overall the test passed since there is no assertion on the deletion being successful.

Paint3DTest

  • All tests fail
  • The UIAutomation element name changed for the eraser. There is an open PR to fix the problem. After fixing the eraser problem all tests continue to fail.

PaintTest

  • All tests fail. Paint is opened but no actions are performed.

After spending 2 hours reading though the documentation and trying the samples I don't feel encouraged. I'm hesitant about any investment in using winappdriver.

soul4soul avatar Feb 11 '20 16:02 soul4soul

@hassanuz Is Appium.WebDriver the go forward path for this project over Microsoft.WinAppDriver.Appium.WebDriver? Should solutions with Microsoft.WinAppDriver.Appium.WebDriver work in the meantime?

brubakerjeff avatar Feb 11 '20 20:02 brubakerjeff

@brubakerjeff Using Microsoft.WinAppDriver.Appium.WebDriver was the only thing that worked for me.

shogerr avatar Feb 11 '20 20:02 shogerr

@shogerr which samples in particular? I'm working with notepadtest which I'm thinking should be straight forward. Were you able to get the notepad example to work?

I receive the error below (WinAppDriver.Exe however successfully launches notepad)

"Message: Class Initialization method NotepadTest.ScenarioEditor.ClassInitialize threw exception. OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException: Unexpected error. Command not implemented: GET: /session/D5492339-528F-4E4F-957A-C92B5E827C1F/title."

brubakerjeff avatar Feb 11 '20 20:02 brubakerjeff

@brubakerjeff I was, and I posted how I was able to get things compiled here https://github.com/microsoft/WinAppDriver/issues/529#issuecomment-572765722.

I didn't have any run time issues with the notepad example.

shogerr avatar Feb 11 '20 21:02 shogerr

Thanks. I believe I am seeing a different issue now. I created a new entry (Error comes from winappdriver) https://github.com/microsoft/WinAppDriver/issues/1061

brubakerjeff avatar Feb 12 '20 00:02 brubakerjeff

@brubakerjeff Using Microsoft.WinAppDriver.Appium.WebDriver was the only thing that worked for me.

@brubakerjeff Can you please help me,how to run simple program for appium. I am getting errors for the capabilities using c#. cannot convert from openqaSelenium.DesiredCapabilities to system.TimeSpan. Please help

Anum-Zargar avatar Feb 23 '20 19:02 Anum-Zargar

Possible fixes

Shakevg avatar Feb 24 '20 06:02 Shakevg

Thanks @kope13 this helped out big time.

One thing to note, it seemed that the WindowsDriver requires a type to be defined, so I modified the last line to:

new WindowsDriver<WindowsElement>(...)

So, the working snippet for me is now:

AppiumOptions opt = new AppiumOptions();
opt.AddAdditionalCapability("app", path);
opt.AddAdditionalCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt);

That's the key!

mcabram avatar Aug 20 '20 05:08 mcabram

Looks like the samples in this repo aren't going to get updated. Does anyone have a link to some updated samples that use a reasonably recent version of the API by any chance?

For example I installed Appium.WebDriver 4.3.1 in a C# project and it's warning me that DesiredCapabilities is obsolete.

grokys avatar Mar 09 '21 14:03 grokys