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.

Having the tests open the WPF Application

See original GitHub issue

I am trying to use Appium to test my WPF application using automation, and I am running into an interesting error. I can get everything working fine if the app is already opened when I got to run the tests and everything passes, but something that I would like for it to do is to open the app when I start the test. The setup method that is run at the beginning of the test looks like this:

public static void Setup(TestContext context)
{
    // Sets up the session so that testing can be done on the application
    if (session == null)
    {
        // Create a new session to bring up an instance of the app
        var capabilities = new AppiumOptions();
        capabilities.AddAdditionalCapability("app", AppId);
        capabilities.AddAdditionalCapability("platformName", "Windows");
        capabilities.AddAdditionalCapability("deviceName", "WindowsPC");
        session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), capabilities);

        Assert.IsNotNull(session);
        Assert.IsNotNull(session.SessionId);

        // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most 3 times(??)
        session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
    }
}

And again, when I go to run the test, if the application is not open, I get the following exception: OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException: Failed to locate opened application window with appId: AppId, and processId: 26896

Is there any way to make is so that you can fix this so that the tests will open the application instead?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
evansctcommented, Jul 8, 2020

I was doing a bit more looking and I found this stackoverflow question that fixed the issue. For whatever reason I just had to set the working directory to the path of the WPF app. But this is solved now!

https://stackoverflow.com/questions/19969693/launch-wpf-application-using-process-start

0reactions
anunay1commented, Jul 8, 2020

What you are doing is correct. As I also do the same way what you are doing, but if the application does not even start with Process.Start that that is a problem with you application, we can have a hangout call(I am available now)anunayathakur1@gmail.com

Read more comments on GitHub >

github_iconTop Results From Across the Web

Launch and call methods on WPF app from unit test project
The basic structure is to set up a thread suitable for running the WPF UI (it has to be an STA thread, and...
Read more >
Test Run: Automating UI Tests In WPF Applications
In this month's column, I show you how to write UI test automation for Windows Presentation Foundation (WPF) applications. WPF applications use a...
Read more >
How to Unit Test a WPF App - YouTube
Do test driven development to add nunit tests to a wpf application.
Read more >
Testing WPF Applications with Test Studio - YouTube
See how easy is to record tests on your WPF application. - Learn more about Testing WPF Apps with Test Studio: ...
Read more >
Testing WPF Applications | TestComplete Documentation
With TestComplete, you can test your 32-bit and 64-bit WPF applications. You can record and replay various interactions with WPF applications, ...
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