【问题标题】:How to use WindowsDriver in Appium to wait for an element to load before clicking on it如何在 Appium 中使用 WindowsDriver 等待元素加载后再单击它
【发布时间】:2018-08-17 13:03:26
【问题描述】:

我正在使用带有 Windows 驱动程序的 Appium 来测试我的基于 Windows 的点网应用程序。我正在尝试通过我的自动化测试单击链接。 当我的自动化测试正在运行时,它不会等到应用程序中的元素(链接)被加载/可见。因此,我的测试失败了。 是否有 WinAppDriver /Windows Driver waittillElementisvisible 属性(就像我们在 Selenium Webdriver 中的那样),以便它等待元素加载? 非常感谢任何帮助。

【问题讨论】:

    标签: appium


    【解决方案1】:
     do
            {
            WebElement element =  ((WindowsDriver) webDriver).findElement(by, using);
            try {
                    if ( element != null ) {
                        element.click();
                        Thread.sleep(500);
                        return;
                    }
    
                } catch (Exception e) {
                    logger.debug("Couldnt find element using byType " +by + " locator " + using + " because of exception" + e.getMessage());
                    attempt++;
                    try {
    
                        Thread.sleep(500);
                    } catch (InterruptedException e1) {
                        logger.debug("Exception while sleeping " + e.getMessage());
                    }
    
                }
            } while (attempt < 5 );
            throw new WebDriverException("Couldnt find element using byType " +by + " locator " + using );
    

    【讨论】:

    • 感谢您的回复,但我使用的是 Windows 驱动程序而不是 WebDriver,因为我的应用程序是基于桌面的应用程序,而且它不支持 Wait / FluentWait ,它如何支持 WebDriver (WebDriverWait)。
    • 我已经编辑了我的答案,你能检查一下它是否有效吗?我找到了这个解决方案here
    • 这行不通,因为我没有 WebElement 但 WindowsElement 和“By”定位器也没有在 WinAppDriver 中实现。我想要一些适用于 Windows 元素而非 Web 的 WinApp 驱动程序实现。
    猜你喜欢
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    相关资源
    最近更新 更多