Win App Driver: How can you run tests on another machine - winappdriver

I am really from a Coded UI background and have started using Win App Driver to test a WPF application. Please forgive me if I am missing something about Win App Driver. The good news is that it works on my development machine!
When I developed Coded UI tests, I could copy my ordered tests and my test application dll to any machine, install VS Test Agent and run my tests there. That way, our customers etc can run our automated tests without having Visual Studio etc and VS Test Agent is free.
I ran the tests from a windows batch file like the one below.
C:
cd codedui
set mstestPath="C:\Program Files (x86)\Microsoft Visual
Studio\2017\TestAgent\Common7\IDE"
%mstestpath%\mstest /testcontainer:WinAppD_OrderedTest-
AcceptanceTest_Logon.orderedtest
pause
My question is can I do this with my Win App Driver tests? I have tried and it said it couldn't find "appium-dotnet-driver.dll" and "WebDriver.dll", I copied them into the same folder as my ordered test, bat file etc and then it asked for another 3 dlls ("Newtonsoft.dll", "WebDriver.Support.dll" and "Castle.Core.dll"). I copied those 3 over as well.
Now it simply says it can't find "Castle.Core". What confuses me is that it asked for 5 dlls, I copied them and that fixed the problem for the first 4, why doesn't it find Castle.Core.dll? Alternatively, is there a simpler, more Win App Drivery way to do this?
Many thanks for any advice from a Coded UI tester who wants to make the transition to Web App Driver!

Instead of manually copying files, it would be much better to configure your dependencies as nuget packages and then just perform a nuget restore on your remote server.
Microsoft provides the Appium.WinAppDriver nuget package which, when added to your UI test project, will provide all the required functionality to test your project.
If using version 4.0 of the package or greater, the docs on GitHub are slightly out of date. You should use the AppiumOptions() API to create a new session
// Set up the session
var opt = new AppiumOptions();
opt.AddAdditionalCapability("app", #"path/to/your/application.exe");
opt.AddAdditionalCapability("platformName", "Windows");
var session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt);
// Click a button
session.FindElementByName("MyButtonName").Click();
// Tear down
session.Close();
session.Dispose();

Related

Create a MSIX bundle containing a UWP app and a Windows service

I have read in some threads that MSIX will start to support also windows services from the January build. But I only seem to find information of how to migrate an existing installer containing a service to MSIX. How should I do if I want to create a completely new MSIX bundle from scratch, containing a UWP project and a Windows Service? I can´t seem to find no information about this no matter how much i search. If someone have succeeded in this it would be vary appriciated to hear how you did this!
I have a sollution in visual studio containing  a UWP project and a Windows Service Project. I try to simply add those two projects to a new windows application packaging project but no matter how I do this I only manage to install the UWP app from the created bundle. Is it still not possible to include the Service project in my MSIX? I get no errors when I build my sollution. I have simply added the UWP project and the service under "Applications" in my windows Application Packaging project.
I have also read that background tasks may be prefered to services in msix packages. But I am afraid that a background task may be a bit too limitied for my intentions. My main requirement for a service is not to have something running in the background, but to access functions outside the UWP sandbox. Like USB storage and other functionality. But maybe this can be achieved by a background task as well?
Maybe the MSIX sollution is a bad idea in my case, do you think I need to relay on some other packaging sollution for my projects instead? Like Wix or similar? I have very little experience in packaging installations so I prefer a tool that is as simple as possible.
The recommendation for apps in development is to use background tasks instead of trying to add a Windows Service. 
For the case where you're trying to access content outside the UWP container, you can consider adding a desktop extension component to your UWP package and then using that for your required functionality. Have a look at this blog post for more details - https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

Compileing my blank console application with a setup Microsoft visual studio 2015

so i have a console application that stitches a pdf into one big long tif however when i go to make a setup project it all seems to work fine until i move the installer to another commutator and run it it installs fine however whenever i run the application it gives an error
The program can't start because ucrtbassed.dll is missing from your computer
i have seen videos where when they add the primary output some msm file is added depending on the library's used in he code however no such file appears when i add my output in the application folder section in the main setup file
edit::
i feel that i cant explain this correctly and thus will upload it as and image this is the main application file inside of the setup project it looks like its only copying the source code when it should also include some dlls
application folder on the setup wizard
You are shipping a debug version of your app, and it is failing because it is asking for the debug version of the Universal CRT (that's why there is a "d" on the end, and it's actually ucrtbased.dll). In general the debug versions of these are available for debugging on developer's machines, not for client machines. So build a release version of your app and see what it does. If it fails looking for ucrtbase.dll, then clients can use this to install it:
https://www.microsoft.com/en-us/download/details.aspx?id=48234

Open prepopulated SQLite database in Cordova

I am developing a cross platform (Android, IOS, WP) application that needs to have a relatively large prepopulated database. I am using Visual Studio 2013 with Cordova plugins.
Most answers on the internet point here or here. However these links always start with "copy your prepopulated database to the assets folder".
In my Visual Studio project, there is no assets folder. This is what I have:
How should I go about this? Preferably the solution should work on all platforms. Thanks.
No need to copy or to insert the values at first run of your app.
Instead use openDatabase with createFromLocation param as described here:
http://redwanhilali.com/ionic-sqlite/
The SQLite forces you to create THE COMPLETE Database executing "Create Tables" commands in a function inside the App, right?
That function ONLY executes if the Database DON'T EXIST. If already exists = don't execute that function!
So... to the "CREATE TABLE" commands, add "INSERT INTO" commands with what you need to populate! This will only execute the first time.
If you want a cleaner code, you can put all the data in an Array and then execute the Inserts with a For Loop.
(I did this in many Apps and worked like a charm!)
ADDED:
To solve "Code Brevity" I suggest 2 Options:
Option 1 - XML File: Add an external XML file with the info, and just read it in the "create db" function, and execute the "inserts" in a For Loop reading the XML file.
Option 2 - create a special js file (name it "populateDB.js" for example!) and enter all the code there... you won't see the code again!
I hope it helps because you cannot include a DB in your project, you HAVE to create it on the device...
I like your question. It made me think about an upcoming project and how I am going to solve a similar issue.
The link you shared: http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html is a good place to start. The "assets" directory referenced isn't visible because, through Visual Studio you are looking at the Windows platform version of the code. Note, in the Xcode/iOS screen capture in the link you reference, the database file isn't in an assets folder, but rather "Resources" that roughly equates to assets within the Android project.
You will need a Mac and Xcode to build your project for iOS, this can not be done with Visual Studio or on a Windows machine. When the project is created by cordova with the "cordova platform create ios" command, you will see a resources directory and you can continue with your instructions.
Similarly, with Android you can open the Android project in Eclipse, or another editor/file browser and do the same. Myself, I am not brave enough (lack of experience) with Visual Studio to browse other platforms in a Visual Studio Solution.
ADDED NOTE: At http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html be sure to read through the recent discussions/comments with regard to copying the file into place within the app. Appears to still work fine, but the process has changed slightly with newer versions of Cordova.
When using Visual Studio (and Phonegap), you cannot see assets folder. If you would like to develop prepopulated DB in Visual Studio, you had better apply sqlite plugin.
You need two plugins.
1) Cordova-sqlite-evcore-extbuild-free
2) cordova-plugin-dbcopy ->this plugin will copy your database to assets folder.
I think the following Git will help you.
https://github.com/ymochi/prepopulated-DB-for-hybrid-applications

How can I properly publish my Windows desktop application in such a way that will ensure the end user has the right files needed to run it?

I have created a small desktop application using .NET 4 for generating an authentication string. It runs fine on my Windows 7 computer, however when I deployed it to our QA guy on his Vista machine, it gave him an error saying he needed to install .NET 4... FAIR ENOUGH. We installed .NET 4, however the next error said that "Microsoft.Web.Infrastructure.dll" was missing from the GAC. Crap. So I poked around a bit and found this:
I then set Publish Status of Microsoft.Web.Infrastructure.dll to Include and published again. This time it gave him an error about "System.Web.Mvc"! So I knew I was on to something. So I went and did this:
However, now when he runs it it just says it can't download files required to run the application, and will not specify what they are!
How can I properly publish my Windows desktop application in such a way that will ensure the end user has the right files needed to run it?
Note: I think Razor and MVC are included because this windows desktop app project is dependent on some other projects in this solution that are using MVC. (Basically this desktop app is using some of the Models.)
Edit: Here is the end result (README was added by me not VS)
As it turned out, the second screen shot view with everything set to Include was the proper way and worked fine while the first screen shot caused missing DLL errors during install. It really was just an FTP upload user error that had the installer looking for a folder that was not there, which is why the second version did not work the first time.
I think you should be looking in the Prerequisites dialog from the Publish tab of the project Properties window, not the Application Files dialog. Not sure if this is an SP1 feature or not (I have SP1).
Image reply from Ryan (question poster):

Visual Studio: How to deploy a solution and continue developing it

I have a solution that I would like to run each day, but simultaneously continue development on it. While it is running, when I attempt to build a new version I receive the error that "Unable to copy file "obj\x86\Debug\Solution.exe" to "bin\Debug\Solution.exe". The process cannot access the file . . . ". This is perfectly understandable: the currently running version has a lock on the .exe, so a new one cannot be created.
My question is this: what is the best practice to "release" the current version to run each day, while keeping a separate "debug" version available for development? My current approach is to create a separate copy of the project, but that is very tedious. Is there a better way?
Thank you,
Ben.
Build a Release Version, run it from folder. (Set Solution Configuration to Release)
Develop and debug in debug mode.
Assuming this is a Winforms or WPF app you can right click on your project, click on Properties and go to Publish tab. From there you can publish your app to a UNC path, install from there and run it while continuing development from within the Visual Studio IDE.
Edit: Additional advantage of this approach is that when you have a new version you will be able to publish to the same location and the next time you start your app it will be automatically updated.
Are you using any source control system? It's not clear if your problem is simply the mechanics of making a build, or how to keep a copy of your source that corresponds to each build. If the answer is b, then a source control system is designed to solve this problem.
You would make a build each day and publish/release the binaries, while at the same time checking in your source code. That way you have a "copy" of your source code that corresponds to each released build, while still allowing you to continue active development.
I would use a post-build script to simply copy the resulting EXE to a new location. You can run it from there easy enough. You can even execute it in the script if you don't like double-clicking ;)

Resources