错误如“ WebDriverError:找不到这样的上下文。”用量角器运行本机应用程序appium时

时间:2019-04-15 15:50:00

标签: jasmine protractor appium

我正在使用带有Jasmine的量角器在appium的帮助下自动执行本机应用程序。应用程序正在Emualator上启动,但几秒钟后关闭。控制台错误显示为“ E / runner-无法启动WebDriver会话。&E / launcher-错误:WebDriverError:找不到此类上下文。”

我曾尝试将Webview部分添加到功能中以检查是否有效。还有鸦片的论点。同样的问题也出现在移动设备上。

CONFIG.JS

const host = "127.0.0.1"; // default appium host
const port = 4723; // default appium port

    exports.config = {
     // Framework to use. Jasmine is recommended.
    framework: "jasmine2",
    baseUrl: 'http://127.0.0.1:5858',
    SELENIUM_PROMISE_MANAGER: false,

    seleniumAddress: "http://" + host + ":" + port + "/wd/hub",
    //seleniumServerJar='../node_modules/protractor/node_modules/webdriver- manager/selenium/selenium-server-standalone-3.141.59.jar',

    //maxInstances: 1,
    specs: ["./specs.js"], // importing/requiring step definition files

    capabilities: {
    automationName: "Appium", //automation engine to use like Appium (default) or Selendroid or UiAutomator2 or Espresso
    appiumVersion: "1.11.1", // Appium module version
    browserName: "", // browser name is empty for native apps or 'Chrome', 'Chromium', or 'Browser' for Android
    platformName: "android", //mobile OS platform to use
    autoWebview: true, //For mobile web
    WebContentsDebuggingEnabled: true,
    autoWebviewTimeout: 10000,
    appPackage: "com.google.android.calculator", // Package name of your app
    appActivity: "com.android.calculator2.Calculator", // App activity of the app 
    appWaitDuration: 8000, // wait for the appWaitActivity to launch (default 20000)
    //platformVersion: "9.0.", // Android platform version of the device
    deviceName: "Android Emulator" // device name of the mobile device or Android Emulator
    },

      // services: ["appium"],
     // appium: {
    //   args: {
    //     commandTimeout: "11000"
    //   }
    // },

    /**
      * hooks help us execute the repeatitive and common utilities
     * of the project.
     */
    // onPrepare: function() {
    //   // implicit and page load timeouts
     //   console.log("<<< NATIVE APP TESTS STARTED >>>");
    // },

    // onComplete: function() {
    //   console.log("<<< TESTING FINISHED >>>");
    // }
  };

Package.json 

  `  <code>{
  "name": "appium-webdriverio-tests",
  "version": "1.0.0",
  "description": "Test framework for automating mobile apps with appium using webdriverio & typescript!",
  "main": "index.js",
  "scripts": {
    "build": "tsc",
    "clean": "rimraf typeScript/",
    "clean-build": "npm run clean && npm run build",
    "appium": "appium",
    "app-test": "protractor config.js",
    "pretest": "npm run clean-build",
    "test": "npm run app-test"
  },
  "keywords": [
    "appium",
    "webdriverio",
    "typescript",
    "mobile automation",
    "jasmine",
    "selenium",
    "webdriverJS",
    "automation testing"
  ],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@types/jasmine": "^2.8.8",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^10.3.4",
    "@types/webdriverio": "^4.10.2",
    "appium": "^1.11.1",
    "protractor": "^5.4.2",
    "rimraf": "^2.6.2",
    "ts-node": "^6.1.1",
    "tslint": "^5.10.0",
    "typescript": "^2.9.2",
    "wdio-appium-service": "^0.2.3",
    "webdriverio": "^4.12.0"
  },
  "dependencies": {
    "wdio-jasmine-framework": "^0.3.6",
    "wdio-sauce-service": "^0.4.14",
    "wdio-selenium-standalone-service": "0.0.12",
    "webdriverio": "^4.13.2",
    "selenium-standalone": "^6.0.1",
    "selenium-webdriver": "^3.0.0-beta-3",
    "wd-bridge": "0.0.2"
  }
}

> ERROR ON TERMINAL


[20:35:57] I/launcher - Running 1 instances of WebDriver
[20:35:57] I/hosted - Using the selenium server at http://127.0.0.1:4723/wd/hub
[20:36:15] E/runner - Unable to start a WebDriver session.
[20:36:15] E/launcher - Error: WebDriverError: No such context found.
    at Object.checkLegacyResponse (C:\Users\***\Documents\APPIUM_Framework\AppiumJasmine\appium-webdriverio-typescript\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (C:\Users\***\Documents\APPIUM_Framework\AppiumJasmine\appium-webdriverio-typescript\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\Users\***\Documents\APPIUM_Framework\AppiumJasmine\appium-webdriverio-typescript\node_modules\selenium-webdriver\lib\http.js:441:30)
    at process._tickCallback (internal/process/next_tick.js:68:7)
[20:36:15] E/launcher - Process exited with error code 100

.

0 个答案:

没有答案