我正在尝试使用Appium和Genymotion(Android模拟器)测试应用程序。
这是我的spec.js
量角器文件:
"use strict";
var wd = require('wd');
console.log(wd.Q);
var wdBridgeModule = require('wd-bridge');
var protractor = require('protractor');
var wdBridge = wdBridgeModule(protractor, wd);
exports.config = {
specs: ['tests/e2e/e2e.js'],
framework: 'jasmine',
capabilities: {
'platformName': 'Android',
'platformVersion': '6.0',
'deviceName': 'Android Device',
'autoWebView': true,
'autoWebviewTimeout': 10000,
'app': "C:/src/app-v5/platforms/android/build/outputs/apk/android-x86-debug.apk",
'fullReset': true,
'browserName': ''
},
onPrepare: function () {
var SpecReporter = require('jasmine-spec-reporter');
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: ''}));
wdBridge.initFromProtractor(exports.config);
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function (){}
},
seleniumAddress: 'http://localhost:4723/wd/hub'
};
我用webdriver-manager start
启动webdriver,然后在不同的终端窗口上运行appium &
,在另一个终端窗口中我启动量角器spec文件。
webdriver 没有任何错误
Appium& 以以下日志终止:
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 2.365
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Android\adk\sdk\platform-tools\adb.exe with args: ["-P",5037,"-s","192.168.56.102:5555","shell","ps","uiautomator"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[Appium] Removing session d772ce79-f1c5-4fbe-b073-d4a4ae602570 from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/d772ce79-f1c5-4fbe-b073-d4a4ae602570 200 1687 ms - 76
量角器规范文件,内容如下:
[15:22:46] I/hosted - Using the selenium server at http://localhost:4723/wd/hub
[15:22:46] I/launcher - Running 1 instances of WebDriver
[15:22:54] E/runner - Unable to start a WebDriver session.
[15:22:56] E/launcher - Error: WebDriverError: Method has not yet been implemented
at WebDriverError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:26:26)
at Object.checkLegacyResponse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\error.js:580:13)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:360:15
at Promise.invokeCallback_ (C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1329:14)
at TaskQueue.execute_ (C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2790:14)
at TaskQueue.executeNext_ (C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2773:21)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2652:27
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
at process._tickCallback (node.js:406:9)
[15:22:56] E/launcher - Process exited with error code 100
我的设置有什么问题?
Appium: 1.5.2
节点 5.8.0
npm: 3.7.3
感谢您提供任何帮助和建议
修改
现在正在运作。我更改了我的量角器配置文件,如下所示:
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
specs: ['tests/e2e/e2e.js'],
//framework: 'jasmine',
capabilities: {
'platformName': 'android',
'platformVersion': '6.0',
'deviceName': 'android emulator',
//'autoWebView': true,
//'autoWebviewTimeout': 10000,
//'app': "C:/src/app/platforms/android/build/outputs/apk/android-x86-debug.apk",
//'fullReset': true,
'appium-version': '1.5.2',
'browserName': 'chrome',
"nativeInstrumentsLib":true
},
baseUrl: 'http://localhost:8100',
onPrepare: function () {
//var SpecReporter = require('jasmine-spec-reporter');
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: ''}));
var wd = require('wd'),
protractor = require('protractor'),
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
}
//jasmineNodeOpts: {
// showColors: true,
// defaultTimeoutInterval: 30000,
// print: function () {
// }
//},
};
更新了所有内容,现在它可以在我的机器上正常运行