问题
I'm trying to just run the calculator test C# example (https://github.com/Microsoft/WinAppDriver/tree/master/Samples/C%23/CalculatorTest) inside visual studio 2017. When I download and build the example, it shows several lines as deprecated;
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", CalculatorAppId);
appCapabilities.SetCapability("deviceName", "WindowsPC");
and one as an error that needs to be changed;
CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1.5));
to
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
. I get errors such as this for each test (Addition, division, Multipluication, Substraction, Templatized) when I try and run them:
Test Name: Addition Test FullName: CalculatorTest.ScenarioStandard.Addition Test Source: C:\Users[user]\Downloads\WinAppDriver-master\Samples\C#\CalculatorTest\ScenarioStandard.cs : line 32 Test Outcome: Failed Test Duration: 0:00:00
Result StackTrace: at OpenQA.Selenium.Appium.AppiumDriver1..ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout) at OpenQA.Selenium.Appium.AppiumDriver1..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[user]\Downloads\WinAppDriver-master\Samples\C#\CalculatorTest\CalculatorSession.cs:line 42 at CalculatorTest.ScenarioStandard.ClassInitialize(TestContext context) in C:\Users[user]\Downloads\WinAppDriver-master\Samples\C#\CalculatorTest\ScenarioStandard.cs:line 101 Result Message: 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..
I have Appium downloaded and running in the background when I do this, but it appears to sit brick like.
I'm a c# app developer, and really don't have a clue what I'm doing with Appium/WinAppDriver (I've just been told to figure it out), and after looking at this for a bit am at a loss as how to troubleshoot whats going on here. I don't know if this is an Appium issue, a WinAppDriver issue, or something else, and help would be appreciated.
回答1:
Solved by updating (inside vs) to the latest beta drivers (4.0.0.4-beta) and then converting code to use the new format.
Use:
AppiumOptions options = new AppiumOptions();
ptions.AddAdditionalCapability("deviceName", "WindowsPC");
options.AddAdditionalCapability("platformName", "Windows");
options.AddAdditionalCapability("app", NotepadAppId);
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), options);
Rather then the shown
DesiredCapabilities appCapabilities = new DesiredCapabilities();
回答2:
Dude, I didn't have any luck at all with those examples but what I have managed to do is launch an application from it's filepath and test that. I also had to figure out that you must set "Developer Mode" to On (nobody tells you that!) and a few other things. Here are my notes that I made for myself and other developers...
Installing and Running Windows Application Driver
1.Download Windows Application Driver installer from https://github.com/Microsoft/WinAppDriver/releases
2.Run the installer on a Windows 10 machine where your application under test is installed and will be tested
3.Set Developer Mode to On (Start -> type "Use Developer Features"), open that and set Developer Mode On...
4.Run WinAppDriver.exe from the installation directory (E.g. C:\Program Files (x86)\Windows Application Driver)
Install Win App Driver Recorder, then launch it. Click the little yellow rectangle icon at the top of it.
https://github.com/Microsoft/WinAppDriver/releases
Using the above, the examples begin to make more sense but as I said, I have only tested apps where I can launch the executable from it's filepath...
来源:https://stackoverflow.com/questions/54114128/appium-winappdriver-c-sharp-calculator-example-error