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.
Solved by updating (inside Visual Studio) to the latest beta drivers (4.0.0.4-beta) and then converting code to use the new format.
Use:
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("deviceName", "WindowsPC");
options.AddAdditionalCapability("platformName", "Windows");
options.AddAdditionalCapability("app", NotepadAppId);
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), options);
Rather than the shown
DesiredCapabilities appCapabilities = new DesiredCapabilities();
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...
Related
I'm trying to automate EXE installation using Appium driver. Taken AutomationID/Name/Classname from EXE installation wizard by using inspect tool. Its creating desktop session. But, it's unable to interact with Install Shield Wizard Windows installer. Getting error message like "An element could not be located on the page using the given search parameters".
Please provide any solution or suggestion to handle this issue.
AppiumDriver<RemoteWebElement> NotepadSession;
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.setCapability("app", #"C:\Windows\System32\notepad.exe");
NotepadSession = new WindowsDriver<RemoteWebElement> (new URL("http://127.0.0.1:4723"), appCapabilities);
NotepadSession.FindElementByClassName("Edit").SendKeys("This is some text");
By using above code able to launch the notepad. But, Its not doing any action on it.
Referred
We are doing investigation for the Test Clouds for our Android and IOS apps. I made a test snippet which installs and launches the android app. And then takes the screenshot. I am using Visual Studio to write the tests. And Visual Studio emulator to run the android app and xamarin test. Xamarin test is able to install the app, but then throws the error. Code and Errors can be found below.
Other observations:
I am using Test account for my investigations which is free for 30 days.
But I don't see my computer added in the link: https://store.xamarin.com/account/my/subscription/computers. While, I have logged in from Visual Studio in my PC.
Due to this I can't copy the license file too. Can that be the reason? If yes, what is the best way to investigate this without getting full subscription.
Code:
[TestFixture]
public class Tests
{
AndroidApp app;
[SetUp]
public void BeforeEachTest()
{
// TODO: If the Android app being tested is included in the solution then open
// the Unit Tests window, right click Test Apps, select Add App Project
// and select the app projects that should be tested.
app = ConfigureApp
.Android
// TODO: Update this path to point to your Android app and uncomment the
// code if the app is not included in the solution.
.ApkFile(#"C:\MobileOnly\SampleProjects\AndroidSampleProjects\InfraTest\app\build\outputs\apk\app-debug.apk")
// .InstalledApp("com.microsoft.mobile.infratest")
.StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear);
}
[Test]
public void AppLaunches()
{
app.Screenshot("First screen.");
}
}
Error:
Test Name: AppLaunches
Test FullName: XamarinUITest.Tests.AppLaunches
Test Source: : line 0
Test Outcome: Failed
Test Duration: 0:00:11.233
Result StackTrace:
at Xamarin.UITest.Shared.Processes.ProcessRunner.Run(String path, String arguments)
at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstallPackage.Execute(IProcessRunner processRunner, IAndroidSdkTools androidSdkTools)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.InstallApps(ApkFile[] apkFiles)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.EnsureInstalled(ApkFile appApkFile, ApkFile testServerApkFile)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at XamarinUITest.Tests.BeforeEachTest() in C:\MobileOnly\SampleProjects\AndroidSampleProjects\XamarinUITest\XamarinUITest\Tests.cs:line 22
Result Message:
SetUp : System.Exception : Failed to execute: C:\NugetCache\androidsdk.23.0.4\platform-tools\adb.exe -s 169.254.138.177:5555 install "C:\Users\gunjansa\AppData\Local\Temp\uitest\a-6EAAB1A4CD21F05DB755FBC781EAD620D4ADACBC\final-D9BA1DA5963F9B7853DABC6DEC56BFF2F4740ADE.apk" - exit code: -1073740940
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
pkg: /data/local/tmp/final-D9BA1DA5963F9B7853DABC6DEC56BFF2F4740ADE.apk
Update the Xamarin.UITest NuGet and try
public void BeforeEachTest()
{
// TODO: If the Android app being tested is included in the solution then open
// the Unit Tests window, right click Test Apps, select Add App Project
// and select the app projects that should be tested.
app = ConfigureApp
.Android
.StartApp();
}
I would do below actions
Restore your UITest project packages
Make sure that you dont see any app named with the package id though the app is completely uninstalled from the device. Often this is the case where uitests uninstalls the existing version of the app and leaves the folders behind causing this issue.
Hope this resolves your issue.
I have added the Windows Media Player com control into my toolbox and then used the control successfully on a Form in Debug mode.
However, when I try running the application in Release mode it errors with...
Could not load file or assembly
'Interop.WMPLib, ... or one of its
dependecies. An attempt was made to
load a program with an incorrect
format.
Through some tracing I've established that the error occurs not when creating the control but on the EndInit method.
Public Sub New
InitializeComponent()
wmp = New AxWMPLib.AxWindowsMediaPlayer()
wmp.BeginInit()
wmp.Enabled = True
wmp.Name = "wmp"
wmp.OcxState = CType(resources.GetObject("wmp.OcxState"), AxHost.State)
Me.Controls.Add(wmp)
Me.Controls.SetChildIndex(wmp, 0)
wmp.Dock = System.Windows.Forms.DockStyle.Fill
wmp.EndInit() ' <<< errors here !
End Sub
What am I missing?
You changed the Platform target setting in the Debug configuration. Possibly weeks ago, maybe even in a previous version of Visual Studio. But didn't change it in the Release configuration. It is one of the settings that is configuration specific.
I'm trying to get WatiN working with MSpec in VS2010, using TestDriven.Net. My code is as follows:
[Subject("Whatever")]
public class when_on_home_page {
private static IE browser;
Establish context = () =>
browser = new IE();
Because of = () => {
browser.GoTo("http://localhost:1234/");
browser.WaitForComplete();
};
It should_show_add_details_link = () =>
browser.Link(Find.ByValue("Add Details")).Exists.ShouldBeTrue();
}
When I run this, the browser loads the page, but when it checks for the link, I get:
Whatever, when on home page
ยป should show add details link (FAIL)
Test 'should show add details link' failed:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at mshtml.IHTMLElementCollection.tags(Object tagName)
at WatiN.Core.Native.InternetExplorer.IEElementCollection.GetElementsByTag(String tagName)
at WatiN.Core.NativeElementFinder.FindElementsByTag(String tagName)
at WatiN.Core.NativeElementFinder.d__2.MoveNext()
at WatiN.Core.ElementFinder.FindFirst()
at WatiN.Core.Element.FindNativeElementInternal()
at WatiN.Core.Element.get_Exists()
NavigationSpecs.cs(20,0): at RoboWeb.Specs.when_on_home_page.<.ctor>b__2()
at Machine.Specifications.Model.Specification.InvokeSpecificationField()
at Machine.Specifications.Model.Specification.Verify()
Having looked around, I checked the following:
VS is running as administrator
TestDriven.Net runs everything in STA mode, apparently
IE has 'protected mode' turned off
I can't add the site to trusted sites, presumably because it's running locally
I call WaitForComplete(), and have also tried Thread.Sleep()
I also tried it with FireFox, but that just crashes.
Any idea what I'm doing wrong here?
These specifications work for me. Actually, I this is my first WatiN spec; I wrote while trying to reproduce the error you received. :-)
The only special thing I had to do was to turn off IE's Protected Mode. I ran the specs
on the command line (see WebSpecs-Watin.cmd in the repo, please compile the specs project and run the web application from VS before running the cmd)
with the TD.Net runner
with ReSharper
They succeed in all three cases. I'm not running as Administrator.
Can you please try to reproduce the error with the project linked above? If you don't have Git installed, there's a download button in the top section.
System.UnauthorizedAccessException can happen in a number of circumstances. If the page has not loaded fully and you try to access an object, as well as simply not being the right user. I would start by debugging through the script manually, and running the test runner as an administrator.
If that works, then try the combinations of admin & full speed, non-admin and full full speed as well as admin and debugging. Then you should have a good idea as to what the real problem. In some rare circumstances (with early early versions of WatiN,) I had to wrap calls in a try - catch then handle this exception, and then re-try after a short wait.
This is driving us crazy... In VS2010, MVC2 projects, not all projects.... both on a project that was upgraded from 2008/mvc1 and on a brand new project created within 2010/MVC2, we have the following behavior:
1) develop as normal..
2) hit F5 or CTRL-F5 to open up a browser
3) works great!
4) add a CSS file (or JS file or any file, or remove any file) in the project
5) immediately the dialog pops up "WebDev.WebServer20.exe has stopped working"
You have to close the program, and "F5" again - and all is right with the world...
Say we then modify an existing css file. No problem. But adding or removing one, immediate crash.
It seems like the development webserver is "locked on" to the project file and when it detects a change, it dies.
The Event Viewer is pretty unhelpful. The following is logged:
Faulting application WebDev.WebServer20.exe, version 10.0.30319.1, time stamp 0x4ba204ca, faulting module KERNEL32.dll, version 6.0.6001.18215, time stamp 0x49953395, exception code 0xe053534f, fault offset 0x000442eb, process id 0x%9, application start time 0x%10.
This is happening on all of our developer workstations, which include some with Windows Sever 2008, some with Windows XP, and some with Windows 7. All are running VS2010 Premium with ReSharper.
Also, the same thing happens on projects which target the 4.0 framework, only the error message referrs to WebDev.WebServer40.exe instead.
Google has revealed nothing. We've already tried "setting a static port" instead of a dynamic port - no help.
Please help if you can.
So, as it turns out, the problem was due to a certain use of MVCTurbine and StructureMap, but it seems likely that the problem would also occur with other IOC Containers, not just StructureMap.
The author of MVCTurbine has expressed that the fix will be in version 2.2 of that product.
In the meantime, one extra line of code in your Global.asax will solve this problem:
//VNEXT: after Turbine 2.2 we wont need this line anymore...
protected override void ShutdownContext() { CurrentContext = null; ServiceLocator = null; }
This article shows the particular use case we were addressing. The "normal plain vanilla" use of MVCTurbine and StructureMap would not have this problem.
Obviously, great thanks to Javier for being so responsive to help requests!