Code is not able to locate my application

I am writing my first code for appium.I am trying to open calculator by passing location to desirable capabilities.
I am passing location of the calculator to desirable capabilities as c:\windows\system32\calc.exe

And when I run my code , I am getting error as

Failed to locate opened application window with appId: C:\Windows\System32\calc.exe, and processId: 230124

My code is in python. And passing desirable capabilities for app as:

Desiredcaps={}
Desiredcaps [“app”]=“C:\Windows\System32\calc.exe”
Desiredcaps [“platformName”]=“Windows”
Desiredcaps [“deviceName”]=“WindowsPC”

I tried with \ and still see error.
Basically the error I am observing is:

“Failed to locate opened application window with appId:C:\Windows\system32\calc.exe , and processId : 230124”

My code is as follows :

import unittest
from appium import webdriver

desired_caps={}
desired_caps["app"]="C:\Windows\System32\calc.exe"
desired_caps["platformName"]="Windows"
desired_caps["deviceName"]="WindowsPC"

driver=webdriver.Remote("http://127.0.0.1:4723" , desired_caps)

driver.find_element_by_name("One").click()

After running this code , calculator does get open , but after that error is thrown as :

"Failed to locate opened application window with appId:C:\Windows\system32\calc.exe , and processId : 230124"

But now if I change the code and pass value for key “app” as :

desired_caps["app"]="Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"

And now if I run the code , then it works fine. It opens calculator , clicks on number One.

Could anyone help me with this?

Why passing the location of the calculator is not working ? And what is that value I am passing to key “app” (Microsoft.WindowsCalculator_8wekyb3d8bbwe!App) , which causes the code to run successfully ?

Why try just one solution and give up? Can’t help you if you won’t help yourself.

Can you try, ‘best practice’ from link?

however best practice is to use the os.path module functions that always select the correct configuration for your OS:

os.path.join(mydir, myfile)

From python 3.4 you can also use the pathlib module. This is equivelent to the above:

pathlib.Path(mydir, myfile)

or

pathlib.Path(mydir) / myfile

I just reinstalled the Windows application driver and it worked. Maybe my windows application driver was not installed properly.

1 Like

Try to include below capability which solved my issue of Failed to locate opened application window with appId"xxx" and process “xxx”

My exe file present in C:\Program Files\MT

appCapabilities.SetCapability(“appWorkingDir”, “C:\Program Files\MT”);

@Rohit_Gawas How do you find the value “Microsoft.WindowsCalculator_8wekyb3d8bbwe!App” for calc.
I am facing this error for all apps.(Excel,word)