如何使用appium和python查找打开的应用程序窗口,以及appId和processId异常?

如何使用appium和python查找打开的应用程序窗口,以及appId和processId异常?,python,selenium,appium,Python,Selenium,Appium,我正在使用appium和selenium测试我的windows应用程序,使用python,我遇到了一个问题。当我运行代码时,它会启动应用程序,但打开窗口需要很长时间。同时,它抛出错误: selenium.common.exceptions.WebDriverException: Message: Failed to locate opened application window with appId: C:\Program Files (x86)\Program\Program.exe, an

我正在使用appium和selenium测试我的windows应用程序,使用python,我遇到了一个问题。当我运行代码时,它会启动应用程序,但打开窗口需要很长时间。同时,它抛出错误:

selenium.common.exceptions.WebDriverException: Message: Failed to locate opened application window with appId: C:\Program Files (x86)\Program\Program.exe, and processId: xxxx
…测试失败。测试失败后,将显示应用程序窗口

我的代码:

    def launcherHandler(self):
        desired_caps = {}
        desired_caps["app"] = Data.path
        desired_caps["appArguments"] = Data.params
        launcherDriver = webdriver.Remote(
            command_executor='http://127.0.0.1:4723',
            desired_capabilities=desired_caps)
        WebDriverWait(launcherDriver, 500).until(EC.element_to_be_clickable((By.NAME, 'Application')))
        launcherrWindow = launcherDriver.find_element_by_name("Application")
        launcherTopLevelWindowHandle = launcherrWindow.get_attribute("NativeWindowHandle")
        launcherTopLevelWindowHandle = hex(int(launcherTopLevelWindowHandle))
        launcherDriver.switch_to.window(launcherTopLevelWindowHandle)
        return launcherDriver
你知道怎么修吗

我在谷歌也找到了这样的解决方案,但我想我已经有了我想要的解决方案:

appCapabilities.SetCapability(“appWorkingDir”, “C:\Program Files\...”);
如果不是,我不知道如何在python中实现它,在我的代码中。 你能帮我做这个吗