appium切换到webview后,获取不了真实的html页面,应该怎么处理?

问题

我使用appium 测试我公司的混合app,使用driver.context("WebView")切换到webview后,调用getPageSource(),返回如下

<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><iframe name="chromedriver dummy frame" src="about:blank"></iframe></body></html>

环境:

appium:1.15.1
OS:Windows 10
API :java
Android:8.1

chrome inspect
chrome inspect 图片
图片说明

配置代码

                capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("deviceName", "b307aa10");
        capabilities.setCapability("automationName", "appium");
        capabilities.setCapability("platformVersion", "8.1.0");
        capabilities.setCapability("appPackage", "com.dayizhihui.dayishi.hpv");
        capabilities.setCapability("appActivity", ".main.view.WelcomeActivity");
        capabilities.setCapability("noReset", "true");
        Map<String, Object> chromeOptions = new HashMap<String, Object>();
        chromeOptions.put("androidPackage", "com.android.chrome");
        capabilities.setCapability(ChromeOptions.CAPABILITY,chromeOptions);

程序代码

                driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        introducePageHandle.clickIntroduceIcon();
        System.out.println("Before " + driver.getContext());
        System.out.println("All Contexts " + driver.getContextHandles());
        driver.context("WEBVIEW_com.dayizhihui.dayishi.hpv");
        System.out.println("After " + driver.getContext());
        System.out.println("PageSource " + driver.getPageSource());

输出如下

Before NATIVE_APP
All Contexts [NATIVE_APP, WEBVIEW_com.dayizhihui.dayishi.hpv, WEBVIEW_chrome]
After WEBVIEW_com.dayizhihui.dayishi.hpv
PageSource <html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><iframe name="chromedriver dummy frame" src="about:blank"></iframe></body></html>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问