0

I'm looking at using Python and WinAppDriver to automate a clickonce application. When the application starts, I get a dialog with a yes and no button on screen.

from appium import webdriver

class TestStuff(unittest.TestCase):

    @classmethod

    def setUpClass(self):
        #set up appium
        desired_caps = {}
        desired_caps["app"] = r"<path to .appref-ms>"
        self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723',desired_capabilities= desired_caps)            

    @classmethod
    def tearDownClass(self):
        self.driver.quit()

    def test_initialize(self):
        self.driver.find_element_by_name("No").click()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestStuff)
    unittest.TextTestRunner(verbosity=2).run(suite)

Now, when I run this script, I see my application launch - but then after a few seconds, I get an error **Failed to locate opened application window with appId: < path to the appref-ms > **

Not sure if this is an issue as a dialog is launching first, rather than the application? But can anyone suggest any other way to attach to the running application?

Joseph
  • 541
  • 1
  • 4
  • 31
  • One additional thing I have noticed (and this is also on a C# version) is that I am getting HTTP 500 errors on the WinAppDriver window. Also - The appId which is being looked for is the full path to the application - surely this will never be the id? – Joseph Feb 12 '21 at 11:08

1 Answers1

0

After a bit of digging about, I think I found what is wrong - this is to help in case any others get into this pickle.

So first, I've found a few places which say ClickOnce applications aren't supported.

So I decided to abandon executing the appref-ms and put in an .exe

This worked, but would throw a .NET error when I clicked on any buttons.

Launching the app from the command line was working also, I could not figure out why.

So I went back to the command line and tried to launch my app with the fully qualified path as the code does - click a button, .NET error.

It turns out you also need to add the "appWorkingDirectory" capability. Also (and this was my misunderstanding) you need to keep the full path in the launcher - I thought since I had the working directory set, I could just put the exe name - this was wrong.)

Joseph
  • 541
  • 1
  • 4
  • 31