Webview在使用Javascript的Appium中不是可用的上下文
我正在使用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
[“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();
是否有人对导致此问题的原因有任何建议