Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webview在使用Javascript的Appium中不是可用的上下文_Javascript_Android_Appium_Appium Android_Cucumberjs - Fatal编程技术网

Webview在使用Javascript的Appium中不是可用的上下文

Webview在使用Javascript的Appium中不是可用的上下文,javascript,android,appium,appium-android,cucumberjs,Javascript,Android,Appium,Appium Android,Cucumberjs,我正在使用Javascript跟踪Appium的锅炉板,返回的唯一可用上下文是[“NATIVE_APP”] 我可以看到,应用程序清单中也设置了,其他主题建议将其修复 帮助文件-WebView.js export const CONTEXT_REF = { NATIVE: 'native', WEBVIEW: 'webview', }; const DOCUMENT_READY_STATE = { COMPLETE: 'complete', INTERACT

我正在使用Javascript跟踪Appium的锅炉板,返回的唯一可用上下文是
[“NATIVE_APP”]

我可以看到,应用程序清单中也设置了
,其他主题建议将其修复

帮助文件-WebView.js

    export const CONTEXT_REF = {
    NATIVE: 'native',
    WEBVIEW: 'webview',
};
const DOCUMENT_READY_STATE = {
    COMPLETE: 'complete',
    INTERACTIVE: 'interactive',
    LOADING: 'loading',
};

class WebView {
    waitForWebViewContextLoaded() {
        driver.waitUntil(
            () => {
                const currentContexts = this.getCurrentContexts();

                return (
                    currentContexts.length > 1 &&
                    currentContexts.find((context) =>
                        context.toLowerCase().includes(CONTEXT_REF.WEBVIEW),
                    )
                );
            },
            10000,
            'Webview context not loaded',
            100,
        );
    }

    switchToContext(context) {
        driver.switchContext(
            this.getCurrentContexts()[context === CONTEXT_REF.WEBVIEW ? 1 : 0],
        );
    }

    getCurrentContexts() {
        return driver.getContexts();
    }

    waitForDocumentFullyLoaded() {
        driver.waitUntil(
            () =>
                driver.execute(() => document.readyState) ===
                DOCUMENT_READY_STATE.COMPLETE,
            15000,
            'Website not loaded',
            100,
        );
    }
        waitForWebsiteLoaded() {
            this.waitForWebViewContextLoaded();
            this.switchToContext(CONTEXT_REF.WEBVIEW);
            this.waitForDocumentFullyLoaded();
            this.switchToContext(CONTEXT_REF.NATIVE);
        }
    
        openWebsiteMenu() {
            const toggle = $('.navToggle');
            toggle.waitForDisplayed(3000);
            toggle.click();
        }
    
        openApiDocs() {
            $('=API').click();
        }
    
        getHeaderPage() {
            const header = $('h1.postHeaderTitle');
            header.waitForDisplayed(3000);
        }
    
        clickOnMenuOption(option) {
            const webdriverProtocol = $(`=${option}`);
            webdriverProtocol.waitForDisplayed(3000);
            webdriverProtocol.click();
        }
    }
    export default WebView;
screenobject文件夹-WebViewScreen.js

import WebView from '../helpers/WebView';
    
const SELECTORS = {
    WEB_VIEW_SCREEN: browser.isAndroid
        ? '*//android.webkit.WebView'
        : '*//XCUIElementTypeWebView',
};

class WebViewScreen extends WebView {
    waitForWebViewIsDisplayedByXpath(isShown = true) {
        $(SELECTORS.WEB_VIEW_SCREEN).waitForDisplayed(20000, !isShown);
    }
}

export default new WebViewScreen();
是否有人对导致此问题的原因有任何建议