Я пытаюсь протестировать приложение Ionic 3 на реальном устройстве с Protractor и Appium. Я использовал эти две статьи, чтобы помочь мне в этом:
Вот мой protractor.conf.js :
/**
* Protractor Config
*/
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
specs: ['./e2e/**/*.e2e-spec.ts'],
multiCapabilities: [{
browserName: '',
appPackage: 'de.softwareforen.mapp.app',
appActivity: '.MainActivity',
platformName: 'Android',
platformVersion: '5.1.1',
deviceName: 'Samsung Galaxy J3 (2016)',
autoAcceptAlerts: 'true',
autoWebView: true
}],
framework: 'jasmine',
SELENIUM_PROMISE_MANAGER: false,
useAllAngular2AppRoots: true,
random: false,
jamineNodeOpts: {
random: false
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
},
beforeLaunch: async () => {
require('ts-node').register({
project: 'e2e'
});
}
}
У меня есть tsconfig.json (как в первой статье) и простой тест в папке "e2e". Приложение было развернуто на устройстве (через ionic cordova run android --device
). Я запускаю appium (пробовал с исполняемым файлом chromedriver и без него, тот же результат) и транспортиром. Приложение на короткое время открывается (~ 3 секунды) на устройстве, но снова закрывается, пока оно находится на заставке.
Это соответствующий вывод прибора:
[debug] [ADB] Running 'C:\Users\JWA\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 420059d197897400 shell am start -W -n de.softwareforen.mapp.app/.MainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[Appium] New AndroidDriver session created successfully, session 33b83913-d588-44ea-a137-033b60db7f56 added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1525769479329 (10:51:19 GMT+0200 (Mitteleuropäische Sommerzeit))
[debug] [MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"browserName":"","appPackage":"de.softwareforen.mapp.app","appActivity":".MainActivity","platformName":"Android","platformVersion":"5.1.1","deviceName":"Samsung Galaxy J3 (2016)","autoAcceptAlerts":"true","autoWebView":true,"count":1},"browserName":"","appPackage":"de.softwareforen.mapp.app","appActivity":".MainActivity","platformName":"Android","platformVersion":"5.1.1","deviceName":"420059d197897400","autoAcceptAlerts":"true","autoWebView":true,"count":1,"deviceUDID":"420059d197897400","deviceScreenSize":"720x1280","deviceModel":"SM-J320F","deviceManufacturer":"samsung"}
[HTTP] <-- POST /wd/hub/session 200 34095 ms - 857
[HTTP]
[HTTP] --> POST /wd/hub/session/33b83913-d588-44ea-a137-033b60db7f56/timeouts
[HTTP] {"script":11000}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted "MJSONWP protocol requires type and ms" and you sent {"script":11000}
[HTTP] <-- POST /wd/hub/session/33b83913-d588-44ea-a137-033b60db7f56/timeouts 400 4 ms - 106
[HTTP]
[HTTP] --> POST /wd/hub/session/33b83913-d588-44ea-a137-033b60db7f56/timeouts
[HTTP] {"type":"script","ms":11000}
[debug] [MJSONWP] Calling AppiumDriver.timeouts() with args: [{"protocol":"MJSONWP","type":"script","ms":11000},"33b83913-d588-44ea-a137-033b60db7f56"]
[debug] [BaseDriver] type: script, ms: 11000
[HTTP] <-- POST /wd/hub/session/33b83913-d588-44ea-a137-033b60db7f56/timeouts 501 8 ms - 118
[HTTP]
[HTTP] --> DELETE /wd/hub/session/33b83913-d588-44ea-a137-033b60db7f56
[HTTP] {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["33b83913-d588-44ea-a137-033b60db7f56"]
[debug] [BaseDriver] Event 'quitSessionRequested' logged at 1525769479399 (10:51:19 GMT+0200 (Mitteleuropäische Sommerzeit))
[Appium] Removing session 33b83913-d588-44ea-a137-033b60db7f56 from our master session list
[debug] [AndroidDriver] Shutting down Android driver
А это вывод транспортира:
[10:50:45] I/launcher - Running 1 instances of WebDriver
[10:50:45] I/hosted - Using the selenium server at http://localhost:4723/wd/hub
[10:51:19] E/runner - Unable to start a WebDriver session.
[10:51:22] E/launcher - Error: WebDriverError: Not implemented yet for script.
at Object.checkLegacyResponse (C:\Users\JWA\Documents\Projekte\MAPP\mapp-app\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\JWA\Documents\Projekte\MAPP\mapp-app\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\JWA\Documents\Projekte\MAPP\mapp-app\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[10:51:22] E/launcher - Process exited with error code 100
Похоже на проблему тайм-аута. К сожалению, я до сих пор не смог ее решить.