WinAppDriver: Couldn't start UWP app - {"error":"unknown error","message":"Element not found. (Exception from HRESULT: 0x80070490)"}}

Greeting,

Using the sample “SimpleCalculatorTests” as a template, I tried to start “HP Smart” app but WinAppDriver yield “Element not found” exception without much details, attaching log below.

No problem with Calculator, or the “Amazon” app with application id: Amazon.com.Amazon_343d40qqvtj1t!App Error with the “HP Smart” app with application id: AD2F1837.HPPrinterControl_v10z8vjag6ke6!App

Code: (modified from SimpleCalculatorTests sample)

import unittest
from appium import webdriver
from time import sleep

class SimpleCalculatorTests(unittest.TestCase):

    @classmethod

    def setUpClass(self):
        #set up appium
        desired_caps = {}
        #desired_caps["app"] = "Amazon.com.Amazon_343d40qqvtj1t!App"
        desired_caps["app"] = "AD2F1837.HPPrinterControl_v10z8vjag6ke6!App"
        self.driver = webdriver.Remote(
            command_executor='http://15.37.176.170:4723',
            desired_capabilities= desired_caps)

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

    def test_initialize(self):
        sleep(20)
        self.assertEqual(1, 1)

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

Log from Ubuntu which executed the test:

hpauto@ubuntu:~/Desktop/test$ python3 test_smart.py 
ERROR

======================================================================
ERROR: setUpClass (__main__.SimpleCalculatorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_smart.py", line 16, in setUpClass
    desired_capabilities= desired_caps)
  File "/home/hpauto/site_lib/Appium_Python_Client-0.22-py2.7.egg/appium/webdriver/webdriver.py", line 36, in __init__
    super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
  File "/home/hpauto/site_lib/selenium-3.11.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/hpauto/site_lib/selenium-3.11.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/hpauto/site_lib/selenium-3.11.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/home/hpauto/site_lib/selenium-3.11.0-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Element not found. (Exception from HRESULT: 0x80070490)


----------------------------------------------------------------------
Ran 0 tests in 2.372s

FAILED (errors=1)

Log from WinAppDriver:

C:\WINDOWS\system32>"c:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe" 15.37.176.170 4723
Windows Application Driver listening for requests at: http://15.37.176.170:4723/
Press ENTER to exit.


==========================================
POST /session HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: Keep-Alive
Content-Length: 128
Content-Type: application/json;charset=UTF-8
Host: 15.37.176.170:4723
User-Agent: Python http auth
X-BlueCoat-Via: 2a84e0f32f31b460

{"desiredCapabilities": {"app": "Amazon.com.Amazon_343d40qqvtj1t!App"}, "capabilities": {"firstMatch": [{}], "alwaysMatch": {}}}
HTTP/1.1 200 OK
Content-Length: 117
Content-Type: application/json

{"sessionId":"FE7E9628-F364-476D-9643-2F8135C5670A","status":0,"value":{"app":"Amazon.com.Amazon_343d40qqvtj1t!App"}}


==========================================
DELETE /session/FE7E9628-F364-476D-9643-2F8135C5670A HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: Keep-Alive
Content-Type: application/json;charset=UTF-8
Host: 15.37.176.170:4723
User-Agent: Python http auth
X-BlueCoat-Via: 2a84e0f32f31b460


HTTP/1.1 200 OK
Content-Length: 63
Content-Type: application/json

{"sessionId":"FE7E9628-F364-476D-9643-2F8135C5670A","status":0}


==========================================
POST /session HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: Keep-Alive
Content-Length: 136
Content-Type: application/json;charset=UTF-8
Host: 15.37.176.170:4723
User-Agent: Python http auth
X-BlueCoat-Via: 2a84e0f32f31b460

{"capabilities": {"firstMatch": [{}], "alwaysMatch": {}}, "desiredCapabilities": {"app": "AD2F1837.HPPrinterControl_v10z8vjag6ke6!App"}}
HTTP/1.1 500 Internal Error
Content-Length: 115
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"Element not found. (Exception from HRESULT: 0x80070490)"}}

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Closing issue due to being resolved with @zavvio 's workaround.

When I asked the development team to use the following instruction to grab the application id, they gave me the same “AD2F1837.HPPrinterControl_85.1.379.0_x64__v10z8vjag6ke6” You can find the Application Id of your application in the generated AppX\vs.appxrecipe file under RegisteredUserModeAppID node. E.g. c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App

It’s also the same value I got from Task Manager > Process > Property

P.S. I get the same error starting some other apps with the same method:

OK (no problem): “Microsoft.SkypeApp_kzf8qxf38zg5c!App” “Microsoft.WindowsStore_8wekyb3d8bbwe!App” “Microsoft.MicrosoftSolitaireCollection_8wekyb3d8bbwe!App”

Fail (same ‘Element not found’ error): “Microsoft.MSPaint_8wekyb3d8bbwe!App” “Microsoft.XboxApp_8wekyb3d8bbwe!App” “microsoft.windowscommunicationsapps_8wekyb3d8bbwe!App” “Microsoft.BingNews_8wekyb3d8bbwe!App”