2gis / Winium.Mobile

Winium.Mobile is Selenium Remote WebDriver implementation for automated testing of Windows StoreApps and Silverlight apps, tested on emulators (currently only Windows Phone/Mobile apps are supported).
Mozilla Public License 2.0
50 stars 29 forks source link

Research WinAppDeploy for Windows 10 Mobile #110

Open NickAb opened 8 years ago

NickAb commented 8 years ago

Windows 10 mobile and Windows 10 Kit (C:\Program Files (x86)\Windows Kits\10\bin\x86) contains some interesting features and code.

This might be very interesting as API provided by Microsoft.Tools.Connectivity lists interesting methods. E.g. RemoteDevice has methods for file manipulation and launching of processes. This is not yet tested, but might be very interesting in context of launching driver as separate background process.

Windows 10 devices (and emulators) can be discovered over network. To enable this feature on device go to Settings -> For Developers and choose Developer mode and enable Device discovery.

To be able to connect to device from host you will have to pair device and host.

  1. On device: press Pair.
  2. On host: run WinAppDeployCmd.exe devices to list devices and note guid or ip of device you are interested in
  3. On host: run WinAppDeployCmd.exe list -guid {0} -pin {1} where {0} is guid of device, {1} is pin displayed by device
  4. On device press Done in Pair device window

For emulators this will keep your device and host paired until restart of device or host. To keep emulator paired after restart create checkpoint and set it as default:

  1. In emulator chrome press Additional Tools button
  2. Navigate to Checkpoints tab
  3. Press New checkpoint
  4. Once checkpoint is created click radio button next to it, so that it becomes default checkpoint.

Now when emulator is restarted, it will load this checkpoint, including pairing status.

Following is a sample of how to deploy application from programmatically using this new interface:

public IRemoteApplication DeployApp(IDevice device, FileInfo appxFile, List<FileInfo> givenDependencies, Guid productId)
{
    string destinationIp;
    string sourceIp;
    int destinationPort;
    device.GetEndPoints(0, out sourceIp, out destinationIp, out destinationPort);

    var deploy = new Deploy();
    var address = IPAddress.Parse(destinationIp);
    var co = new ConnectivityOptions(address);

    if (Device.IsApplicationInstalled(productId))
    {
        Device.GetApplication(productId).Uninstall();
    }

    deploy.DoInstallOrUpdate(co, appxFile, givenDependencies, Deploy.DeployAction.Install, null);

    return device.GetApplication(productId);
}

Notes

NickAb commented 8 years ago

https://blogs.windows.com/buildingapps/2015/07/09/just-released-windows-10-application-deployment-tool/