如何使用 Appium 将上下文切换到嵌入式网页并获取当前 URL?

问题描述 投票:0回答:0

我正在尝试使用 appium 验证我的移动应用程序中的 Web 链接是否重定向到正确的 URL。通过使用上下文切换,我能够在 Android 中轻松地做到这一点。但是我无法让它在 iOS 中工作。我已经阅读了数十篇其他帖子和主题,但它们没有帮助

public String getURL(){
        appContext = ((SupportsContextSwitching) driver).getContext();
        Set<String> contextList = ((SupportsContextSwitching) driver).getContextHandles();
        ((SupportsContextSwitching) driver).context((String) contextList.toArray()[1]);
        return driver.getCurrentUrl();
    }

contextList 在 iOS 中总是只包含 1 个元素,NATIVE_APP。对于 Android,我得到 2,NATIVE_APP 和 WEBVIEW。

我只是使用累了

public String getURL(){
        return driver.getCurrentUrl();
    }

对于 iOS 但随后出现“方法未实现”错误

有没有更好的方法从嵌入式应用程序 Webview 获取 url?我只想获取字符串形式的 url,以便可以对其执行

Assert.assertEqual

注意:

setWebContentsDebuggingEnabled
已启用

java ios webview ui-automation appium-ios
© www.soinside.com 2019 - 2024. All rights reserved.