【问题标题】:Protractor E2E Testing - E/launcher - Error: Error: Cannot find module 'wd'量角器 E2E 测试 - E/启动器 - 错误:错误:找不到模块 'wd'
【发布时间】:2018-01-27 06:45:02
【问题描述】:

我正在尝试使用量角器执行自动化测试,因此当我的应用打开并尝试在输入字段中写入时,返回此消息:

C:\Projetos\Pessoal\ionic_app\tests(主)

量角器 conf.js

[09:23:42] I/launcher - Running 1 instances of WebDriver
[09:23:42] I/hosted - Using the selenium server at http://localhost:4723/wd/hub
[09:25:07] E/launcher - Error: Error: Cannot find module 'wd'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at onPrepare (C:\Projetos\Pessoal\ionic_app\tests\conf.js:18:18)
    at q_1.Promise (C:\Users\c1401314\AppData\Roaming\npm\node_modules\protractor\lib\util.ts:48:39)
    at Function.promise (C:\Users\c1401314\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:682:9)
    at Object.runFilenameOrFn_ (C:\Users\c1401314\AppData\Roaming\npm\node_modules\protractor\lib\util.ts:39:10)
    at plugins_.onPrepare.then (C:\Users\c1401314\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:103:21)
    at _fulfilled (C:\Users\c1401314\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
[09:25:07] E/launcher - Process exited with error code 100enter code here

我使用 Appium 和 Genymotion 来模拟我的 Android 设备

Appium 回报:

    [Appium] Welcome to Appium v1.6.5
    [Appium] Appium REST http interface listener started on 0.0.0.0:4723
    [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"android","platformVersion":"7.0","deviceName":"Nexus","browserName":"","autoWebview":true,"app":"C:\\appium_drivers\\apks\\android-release.apk","count":1}}
    [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"android","platformVersion":"7.0","deviceName":"Nexus","browserName":"","autoWebview":true,"app":"C:\\appium_drivers\\apks\\android-release.apk","count":1},null,null]
    [debug] [BaseDriver] Event 'newSessionRequested' logged at 1503057934342 (09:05:34 GMT-0300 (Hora oficial do Brasil))
    [Appium] Creating new AndroidDriver (v1.24.3) session
    [Appium] Capabilities:
    [Appium]   platformName: 'android'
    [Appium]   platformVersion: '7.0'
    [Appium]   deviceName: 'Nexus'
    [Appium]   browserName: ''
    [Appium]   autoWebview: true
    [Appium]   app: 'C:\\appium_drivers\\apks\\android-release.apk'
    [Appium]   count: 1
[debug] [Chromedriver] Changed state to 'online'
[Appium] New AndroidDriver session created successfully, session 967301ea-6ced-4801-9f5a-e3d6b68c2e7f added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1503059100927 (09:25:00 GMT-0300 (Hora oficial do Brasil))
[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":{"platformName":"android","platformVersion":"7.0","deviceName":"Nexus","browserName":"","autoWebview":true,"app":"C:\\appium_drivers\\apks\\android-release.apk","count":1},"platformName":"android","platformVersion":"7.0","deviceName":"192.168.104.101:5555","browserName":"","autoWebview":true,"app":"C:\\appium_drivers\\apks\\android-release.apk","count":1,"deviceUDID":"192.168.104.101:5555","deviceScreenSize":"1200x1920","deviceModel":"Nexus","deviceManufacturer":"Genymotion","appPackage":"br.com.bematech.staff","appWaitPackage":"br.com.bematech.staff","appActivity":"br.com.bematech.staff.MainActivity","appWaitActivity":"br.com.bematech.staff.MainActivity"}
[HTTP] <-- POST /wd/hub/session 200 78056 ms - 941
[HTTP] --> POST /wd/hub/session/967301ea-6ced-4801-9f5a-e3d6b68c2e7f/timeouts {"type":"script","ms":11000}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/967301ea-6ced-4801-9f5a-e3d6b68c2e7f/timeouts] to [POST http://127.0.0.1:8000/wd/hub/session/98599620f036c57ea39d899794f9b5c0/timeouts] with body: {"type":"script","ms":11000}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"98599620f036c57ea39d899794f9b5c0","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 98599620f036c57ea39d899794f9b5c0 with 967301ea-6ced-4801-9f5a-e3d6b68c2e7f
[HTTP] <-- POST /wd/hub/session/967301ea-6ced-4801-9f5a-e3d6b68c2e7f/timeouts 200 8 ms - 76
[HTTP] --> DELETE /wd/hub/session/967301ea-6ced-4801-9f5a-e3d6b68c2e7f {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["967301ea-6ced-4801-9f5a-e3d6b68c2e7f"]
[debug] [BaseDriver] Event 'quitSessionRequested' logged at 1503059101119 (09:25:01 GMT-0300 (Hora oficial do Brasil))
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_br.com.bematech.staff
[debug] [Chromedriver] Changed state to 'stopping'
[debug] [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/98599620f036c57ea39d899794f9b5c0] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"98599620f036c57ea39d899794f9b5c0\",\"status\":0,\"value\":null}"
[debug] [Chromedriver] Changed state to 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","192.168.104.101:5555","shell","am","force-stop","br.com.bematech.staff"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","192.168.104.101:5555","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[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

这是我的文件夹结构:

--测试 conf.js 规范.js

conf.js

 exports.config={
    seleniumAddress:'http://localhost:4723/wd/hub',
    specs:['spec.js'],
    capabilities: {
        platformName: 'android',
        platformVersion: '7.0',
        deviceName: 'Nexus',
        browserName: "",
        autoWebview: true,

        app: 'C:\\appium_drivers\\apks\\android-release.apk'
    },
    baseUrl: '127.0.0.1:4723',

    onPrepare: function () {
        let wd = require('wd'),
            protractor = require('protractor'),
            wdBridge = require('wd-bridge')(protractor,wd);
        wdBridge.initFromProtractor(exports.config);
    }
};

spec.js

  describe('firstSpecStaff',function () {

          browserName = onPrepare('0.0.0.0', port);
          it('makelogin',function () {
          element(by.id('user')).sendKeys('admin@admin');
          element(by.id('password')).sendKeys('admin');
        });
 });

【问题讨论】:

    标签: javascript protractor android-webview appium e2e-testing


    【解决方案1】:

    您是否将 wd 安装为 npm 模块?例如npm i wd --save-dev

    【讨论】:

    • 我忘记了 --save-dev,但安装并显示相同的错误:'> wd@1.4.0 install C:\Projetos\Pessoal\ionic_app\node_modules\wd > 节点脚本/build-browser-scripts npm WARN 可选跳过可选依赖:fsevents@1.1.2 + wd@1.4.0。在 67.83s' C:\Projetos\Pessoal\ionic_app\tests λ protractor conf.js [12:56:16] I/launcher - 运行 1 个 WebDriver 实例 [12:56:16] I/hosted - 中添加了 149 个包localhost:4723/wd/hub [12:57:25] E/launcher 的 selenium 服务器 - 错误:错误:找不到模块“wd-bridge”
    • 所以你应该也安装这个模块。
    • 我尝试过但没有成功。感谢您的帮助@Oleksii
    猜你喜欢
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-03
    相关资源
    最近更新 更多