Reputation: 13
I am new to WinAppDriver, and I am trying to create an automated test.
I have an app that has a theme.xml file that contains theme info (color of background, font color etc) for multiple themes. this file is in the bin fold with the app exe: EXE is found in \bin\app.exe. Theme file is found in \bin\Themes\Themes.xml
I am able to get the app to start with my first test, but as it is loading, it tries to access the Themes.xml file, but it is looking in the wrong place: Trying to find it in the winappdriver folder - 'C:\Program Files (x86)\Windows Application Driver\Themes\Themes.xml'.
How do I get it to look in the bin folder where the app is?
Here is a code snippet:
private const string CSWAppId = @"C:\Applications\CSW\CSW2\CSWClient\bin\x86\Release\net48\CSWClient.exe";
public WindowsDriver<WindowsElement> Session { get; set; }
public CSWSession()
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability( "app", CSWAppId );
this.Session = new WindowsDriver<WindowsElement>( new Uri( WindowsApplicationDriverUrl ), appCapabilities );```
Upvotes: 0
Views: 1657
Reputation: 79
For a setup program, we need to find its AUMID. For a portalable program, we have another way to connect to it. In Win10, all running GUI programs, their final parent on the visual tree is Desktop, so we need to connect to Desktop first, and then look for the programs we have started in Desktop
Setup Program VS Portalable Program
UI testing for Windows apps with WinAppDriver and Appium
// Set Desktop driver
var desktopCapabilities = new DesiredCapabilities();
var desktopCapabilities.SetCapability("app", "Root");
var desktopDriver = new WindowsDriver<WindowsElement>(new Uri(http://127.0.0.1:4723), desktopCapabilities);
// Find your app window ."CSWClient" is the process name, you can it from TaskManager
var clientWindow = _desktopDriver.FindElementByName("CSWClient");
// Connect to your app
var clientWindowHandle = earthWindow.GetAttribute("NativeWindowHandle");
clientWindowHandle = (int.Parse(earthWindowHandle)).ToString("x");
var clientCapabilitie = new DesiredCapabilities();
clientCapabilitie.SetCapability("appTopLevelWindow", earthWindowHandle);
// Set your app driver
var clientDriver = new WindowsDriver<WindowsElement>(new Uri(http://127.0.0.1:4723), clientCapabilitie);
And then, you can do what want to do.
Upvotes: 1