我正在尝试使用Protractor和Appium在真实设备上测试Ionic 3应用程序。我一直在用这两篇文章来帮助我:
这是我的 protractor.conf.js :
val client = FusedLocationProviderClient(this)
val location = client.lastLocation
location.addOnCompleteListener {
// this is a lambda expression and we get an 'it' iterator to access the 'result'
// it.result.latitude gives the latitude
// it.result.longitude gives the longitude
val geocoder = Geocoder(applicationContext, Locale.getDefault())
val address = geocoder.getFromLocation(it.result.latitude, it.result.longitude, 1)
if (address != null && address.size > 0) {
// Get the current city
city = address[0].locality
}
}
location.addOnFailureListener {
// Some error in getting the location, let's log it
Log.d("xtraces", it.message)
}
我有一个tsconfig.json(就像在第一篇文章中一样)和一个简单的测试文件夹“e2e”。该应用已部署在设备上(通过/**
* 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'
});
}
}
)。我开始appium(尝试使用和不使用chromedriver可执行文件,相同的结果)和量角器。应用程序在设备上短暂打开(约3秒),但仍然在启动屏幕上再次关闭。
这是相关的appium输出:
ionic cordova run android --device
这是量角器输出:
[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
看起来像是超时问题。不幸的是到目前为止我还没能解决它。
答案 0 :(得分:0)
问题是multiCapabilities中的拼写错误。它的autoWeb v 不是autoWebView。