Search code examples
winappdriver

WinAppDriver not working with side loaded Universal Application


I am unable to load a side loaded Windows Universal application using WinAppDriver

I have verified my code works if I try to load the Windows Calculator application but I am unable to load my target application. I get an error message "The system cannot find the file specified". I used the Get-AppxPackage method in PowerShell to get the application information for my target application. The method returned the data structure below:

Name : AACE4B69.MazikAXCashier

Publisher : CN=XXXXXXXXXXX

Architecture : Neutral

ResourceId :

Version : 2.4.1.9

PackageFullName : AACE4B69.MazikAXCashier_2.4.1.9_neutral__gfhc11b3bvd9y

InstallLocation : C:\Program Files\WindowsApps\AACE4B69.MazikAXCashier_2.4.1.9_neutral__gfhc11b3bvd9y

IsFramework : False

PackageFamilyName : AACE4B69.MazikAXCashier_gfhc11b3bvd9y

PublisherId : gfhc11b3bvd9y

IsResourcePackage : False

IsBundle : False

IsDevelopmentMode : False

NonRemovable : False

Dependencies : {Microsoft.WinJS.2.0_1.0.9600.17018_neutral__8wekyb3d8bbwe}

IsPartiallyStaged : False

SignatureKind : Developer

Status : Ok

I have tried to load the application using the following fields in the AppID field:

Name

PackageFullName

PackageFamilyName

[TestFixture]
public class Tests
{

    protected static WindowsDriver<WindowsElement> windowSession;

    public const String AppID = "AACE4B69.MazikAXCashier_2.4.1.9_neutral__gfhc11b3bvd9y";
    public const String driverURL = "http://127.0.0.1:4723";


    [SetUp]
    public void Setup()
    {

        if (windowSession == null)
        {

            // Configure the application connection and load data
            AppiumOptions opt = new AppiumOptions();
            opt.AddAdditionalCapability("app", AppID);

            try
            {
                // Create the driver object
                windowSession = new WindowsDriver<WindowsElement>(new Uri(driverURL), opt);
                Assert.IsNotNull(windowSession);

            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to open application with error: " + e.Message);
            }
        }
    }

    [Test]
    public void Test1()
    {
        Assert.Pass();
    }}

I would expect one of these names to be the required Application ID and result in the app loading. Instead I get the error message "The system cannot find the file specified".

This application is side loaded and I am wondering if there is something different about that. Any help or suggestions are appreciated.


Solution

  • OK, I figured out the trick. I needed to user the PackageFamilyName appended with a qualifier. In my case this came out to be

        public const String AppID = "AACE4B69.MazikAXCashier_gfhc11b3bvd9y!App";
    

    I got this value via a two step process. I used the Powershell Get-appxPackage Mazik to get the PackageFamilyName as I previously did. I then appended "!App" to this string to get the required value. I determined the "!App" string based on another Powershell script I found in an online article. I used the following script to determine what the appended ID value was:

    (Get-AppxPackageManifest (Get-AppxPackage Mazik)).package.applications.application.id

    This returned "App" and I constructed the final string as described above. It looks like the "!App" is the typical ending to the required AppID but I have to assume there are different values for different situations. Once I got the correct AppID value everything worked as expected and the side loaded application was not an issue