我尝试使用Protractor和Appium在Ionic 4项目的真实android设备上运行端到端测试,因为我将cordova插件用于本机功能。我的问题是:当我尝试使用Appium运行E2E测试时,该应用程序会在我的设备上启动,但是Appium却陷入了状态调用,得到了意外的响应,并且代理发送了HTML页面。
我在Linux VM上使用代理服务器,但是在VM和npm中都正确配置了代理服务器。还有其他我应该配置的地方吗?
还有更多信息:
正在运行“ adb设备”:
List of devices attached
ce12171ccbeb793b05 device
我的量角器配置文件(protractor.conf.js):
let path = require('path');
let wd = require('wd');
let protractor = require('protractor');
let wdBridge = require('wd-bridge')(protractor, wd);
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities:
{
platformName: 'android',
platformVersion: '8.0',
deviceName: 'ce12171ccbeb793b05',
automationName: 'UiAutomator2',
browserName: "",
autoWebview: true,
app: path.join(__dirname, '../platforms/android/app/build/outputs/apk/debug/app-debug.apk'),
},
baseUrl: 'http://localhost:8000/',
onPrepare() {
wdBridge.initFromProtractor(exports.config);
}
};
卡在卡住时记录日志:
[debug] [Chromedriver] Chromedriver version: '2.46.628388'
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[WD Proxy] Got an unexpected response: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[WD Proxy] <html><head>
[WD Proxy] <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[WD Proxy] <title>ERROR: The requested URL could not be retrieved</title>
[WD Proxy] <style type="text/css"><!--
[WD Proxy] /*
[WD Proxy] Stylesheet for Squid Error pa...
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[WD Proxy] Got an unexpected response: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[WD Proxy] <html><head>
[WD Proxy] <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[WD Proxy] <title>ERROR: The requested URL could not be retrieved</title>
[WD Proxy] <style type="text/css"><!--
[WD Proxy] /*
[WD Proxy] Stylesheet for Squid Error pa...
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
最后返回这个:
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[debug] [Chromedriver] Changed state to 'stopped'
[Chromedriver] Error: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: 403 - "<!DOCTYPE html PUBLIC \"-//W3C//...
403错误后的HTML告诉我:
ERROR
The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: http://127.0.0.1:8200/wd/hub/status
Access Denied.
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.
我不知道为什么代理服务器拒绝状态请求并显示403错误,并且我不知道它是否可以由我自己配置或仅由代理管理员配置。你有什么主意吗 ?谢谢!