question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automated UI Tests Using Visual Studio Online

See original GitHub issue

Follow on from this issue: https://github.com/microsoft/appcenter/issues/25

FAO: @hassanuz

I am trying to Automate my UWP Ui tests using these instructions:

https://github.com/microsoft/WinAppDriver/wiki/WinAppDriver-in-CI-with-Azure-Pipelines.

I am using a Local Build Server

Step 1: Start WinApp Driver Step 2: Install app using this script:

$currentDirectory = Get-Location

Write-Host "Removing FieldStrike if present"
try
{
    Get-AppxPackage MyApp | Remove-AppxPackage #uninstall App if its present
}
catch
{
    Write-Host "failed to remove FieldStrike"
    Write-Host $Error[0]
    exit

}
Write-Host "Installing MyApp"
try
{
    $installScriptLocation = Get-ChildItem -Path $currentDirectory.Path -Recurse -Filter Add-AppDevPackage.ps1

    powershell.exe -File $installScriptLocation.FullName -Force 
}
catch
{
    Write-Host "Failed to install Fieldstrike"
    Write-Host $Error[0]
    exit
}

This fails with

Error: Could not install the app. To ensure security, please consider uninstalling the signing certificate until you can install the app. Instructions for doing so can be found here:

If I run this script locally it works, so my guess is something to do with the user?

Step 3: after installing app locally try to run UI tests using this script:

$currentDirectory = Get-Location

Write-Host "Running Tests"
try
{

    $uiTests= $currentDirectory.Path + "\nunit3-console.exe"
    $testdll = $currentDirectory.Path + "\MyApp.UI.Tests.UWP.dll"
    $logFile = $currentDirectory.Path + "\TestResults.txt"
    Write-Host $uiTests
    Write-Host $testdll
    Write-Host $logFile
	Start-Process $uiTests $testdll -Wait  -RedirectStandardOutput $logFile -WindowStyle Normal
    
}
catch
{
    Write-Host "Error whilst running tests"
    Write-Host $Error[0]
    Stop-Process -Name  "WinAppDriver"
    exit
}


Write-Host "Tests Completed Results in TestResults.txt"
Get-Content -Path $logFile

Now this runs the tests but they all fail with this error

Unexpected error occured: Creating an instance of the COM component with CLSID {45BA127D-10A8-46EA-8AB7-56EA9078943C} from the IClassFactory failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password. (Exception from HRESULT: 0x8000401A).

Code in the setup method is like so:

            OpenQA.Selenium.Appium.AppiumOptions desktopOptions = new AppiumOptions();
            desktopOptions.AddAdditionalCapability("app", "Root");
            var desktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), desktopOptions);
            app = new WinDriverApp(desktopSession);

It may be the test initialisation code that is wrong, but there are two issues here, cant install the app automatically and can’t run the tests remotely

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JKennedy24commented, Dec 13, 2019

@hassanuz I never did manage to get this automated UWP UI tests up and running in the end.

I had 2 blockers.

  1. I couldn’t configure interactive mode on my local build machine because the machine is on the domain.

  2. When I ran in the cloud the machine didn’t have enough memory to deal with the size of my project and would eventually throw an error which was essentially linked to “out of memory”. Something to do with .Net native tool chain

Conclusion I think the disjointedness of Xamarin and UWP is mad.

The ideal solution would be for Automated UWP UI tests to be part of the TestCloud

0reactions
JKennedy24commented, Jan 14, 2020

I am currently at a bit of a stalemate with this issue being blocked by other bugs/issues.

I am going to close this issue for now and hope that Microsoft provide a better solution in future

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Coded UI tests to test your code - Visual Studio
Coded UI Test Builder records your actions and generates code from them. After the test is created, you can edit it in a...
Read more >
Best Practices for Coded UI Tests - Visual Studio (Windows)
Use the Coded UI Test Builder whenever possible. · Do not modify the UIMap. · Create your test as a sequence of recorded...
Read more >
Create a Coded UI Test - Visual Studio (Windows)
Visual Studio 2019 is the last version where Coded UI Test will be fully available. We recommend using Playwright for testing web apps...
Read more >
Using Different Web Browsers with Coded UI Tests
Visual Studio 2019 is the last version where Coded UI Test will be fully available. We recommend using Playwright for testing web apps...
Read more >
Editing Coded UI Tests - Visual Studio (Windows)
Visual Studio 2019 is the last version where Coded UI Test will be fully available. We recommend using Playwright for testing web apps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found