WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

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

Open zavvio opened this issue 8 years ago • 18 comments

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)"}}

zavvio avatar May 11 '18 00:05 zavvio

Hi Zaavio,

Any update on this issue. Am unable to launch the app with same error. Please help in this regards.

Thanks, Surya

Suryakumarn avatar May 20 '18 13:05 Suryakumarn

No update but made a workaround: start app as "Root", then use the start menu to search and open the app needed to be tested.

Also halted my team's further development on using WinAppDriver after running into couple more fundamental driver problems while the project update/commit rate is close to none; feels like WinAppDriver is close to death when Microsoft shifted their focus into Progressive Web Apps (PWAs) instead.

zavvio avatar May 20 '18 17:05 zavvio

It looks like the app name is incorrect. Amazon.com.Amazon_343d40qqvtj1t!App matched correctly, but AD2F1837.HPPrinterControl_v10z8vjag6ke6!App did not.

Have you tried using a different name, or specifying the literal path to the program (if possible) to check?

PandaMagnus avatar May 21 '18 16:05 PandaMagnus

This is what I got from calling "Get-AppxPackage" on powershell. I don't believe I can start this UWP app directly with its path "C:\Program Files\WindowsApps\AD2F1837.HPPrinterControl_85.1.379.0_x64__v10z8vjag6ke6"; permission issue. I could try further on using the path but that's not the documented way of starting an UWP app...

Name              : AD2F1837.HPPrinterControl
Publisher         : CN=ED346674-0FA1-4272-85CE-3187C9C86E26
Architecture      : X64
ResourceId        :
Version           : 85.1.379.0
PackageFullName   : AD2F1837.HPPrinterControl_85.1.379.0_x64__v10z8vjag6ke6
InstallLocation   : C:\Program Files\WindowsApps\AD2F1837.HPPrinterControl_85.1.379.0_x64__v10z8vjag6ke6
IsFramework       : False
PackageFamilyName : AD2F1837.HPPrinterControl_v10z8vjag6ke6
PublisherId       : v10z8vjag6ke6
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
Dependencies      : {Microsoft.NET.Native.Framework.1.7_1.7.25531.0_x64__8wekyb3d8bbwe,
                    Microsoft.NET.Native.Runtime.1.7_1.7.25531.0_x64__8wekyb3d8bbwe,
                    Microsoft.VCLibs.140.00_14.0.25426.0_x64__8wekyb3d8bbwe}
IsPartiallyStaged : False

zavvio avatar May 22 '18 18:05 zavvio

Hi @zavvio,

Can you confirm whether the APP ID is correct by following these instructions.

hassanuz avatar May 22 '18 22:05 hassanuz

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"

zavvio avatar May 22 '18 22:05 zavvio

Thanks Zavvio. Working with the work around.

Suryakumarn avatar May 23 '18 05:05 Suryakumarn

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

hassanuz avatar Jun 05 '18 23:06 hassanuz

I don't know why this issue is closed. Still, I am facing the same issue.

vnair1986 avatar Dec 05 '18 13:12 vnair1986

org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z' System info: host: 'NOLAPF2FFLWS598', ip: '172.22.56.49', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181' Driver info: driver.version: WindowsDriver at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94) at io.appium.java_client.windows.WindowsDriver.(WindowsDriver.java:42) at com.appium.test.CalculatorTest.setup(CalculatorTest.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:168) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105) at org.testng.TestRunner.privateRun(TestRunner.java:648) at org.testng.TestRunner.run(TestRunner.java:505) at org.testng.SuiteRunner.runTest(SuiteRunner.java:455) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415) at org.testng.SuiteRunner.run(SuiteRunner.java:364) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208) at org.testng.TestNG.runSuitesLocally(TestNG.java:1137) at org.testng.TestNG.runSuites(TestNG.java:1049) at org.testng.TestNG.run(TestNG.java:1017) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185) ... 39 more Caused by: org.openqa.selenium.WebDriverException: Element not found. (Exception from HRESULT: 0x80070490) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1.48 seconds Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z' System info: host: 'NOLAPF2FFLWS598', ip: '172.22.56.49', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181' Driver info: driver.version: WindowsDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:122) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125) ... 44 more

vnair1986 avatar Dec 05 '18 14:12 vnair1986

While @zavvio has presented a work around, doesn't this still represent a real issue with the main functionality of winappdriver? Seems like this should be left open. We are experiencing this same issue.

WinAppDriver V1.1 Selenium V3.12.1 Appium.Webdriver nuget V3.0.0.2

C# unit test: DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!App"); var session = new WindowsDriver(new Uri("http://127.0.0.1:4723"), appCapabilities);

WinAppDriver:

POST /session HTTP/1.1 Accept: application/json, image/png Connection: Keep-Alive Content-Length: 164 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723 User-Agent: selenium/3.12.0 (.net windows)

{"desiredCapabilities":{"app":"Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!App","platformName":"Windows"},"capabilities":{"firstMatch":[{"platformName":"Windows"}]}} 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)"}}

==========================================

hoorncj-student avatar Dec 21 '18 01:12 hoorncj-student

Sorry we'll dig into this.

khouzam avatar Dec 21 '18 01:12 khouzam

Is there an update on this issue? We are using AppiumLibrary in RobotFramework to launch and app and we are getting the same error.

We are PoCing WinAppDriver.exe and Appiumlibrary in RobotFramework/Python as one of the viable solutions for Windows App automation.

Can we get root cause/ETA on a fix for this issue?

YouWhy avatar Mar 01 '19 19:03 YouWhy

Hey there, I searched a while and never really got a clear (or at least clear to me :) ) answer about this problem.

Quick context: I'm also "PoCing" APPIUM for Android/IOS/UWP apps and when it came to Windows I struggled to launch the UWP app by using the "app" capability. It turns out that you can't launch it with !App, App here is NOT a common word/suffix, it's defined by the tag in your AppxManifest.xml file.

<Applications>
    <Application Id="<hereIsTheValueYouWant>" ...

Hope this will help someone else. @YouWhy

PS : you can also get this information by getting installed package properties: Get-AppxPackage *yourAppPartialName* | Format-Wide Name

d2lu avatar Mar 28 '19 10:03 d2lu

Is there an update on the issue? I am facing this same problem when trying to execute the WinAppDriver tests on Bamboo. Locally the tests work OK.

CataUdrea avatar Apr 09 '19 09:04 CataUdrea

Hello @CataUdrea ,

I'm not quite sure there's an issue here, or at least the one encountered by @zavvio or @hoorncj does not appear to be one since they say they used the calculator app code to base their script upon.

The example given by hoorncj is easy to demonstrate (I dont have the HP app under hand ). The app is called with this string: "Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!App" but should be in fact called with this one : "Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!Microsoft.MicrosoftOfficeHub" as explained in my previous post.

d2lu avatar Apr 09 '19 13:04 d2lu

Above solution works for me. thanks.

Amarnath-MD avatar Apr 29 '19 02:04 Amarnath-MD

Your code is Wrong in Place of Webdriver Put Windows driver

RavikumarAyyanar avatar Dec 22 '22 06:12 RavikumarAyyanar