首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配备独立Chrome的Nighwatch

配备独立Chrome的Nighwatch
EN

Stack Overflow用户
提问于 2018-12-03 21:25:16
回答 1查看 46关注 0票数 1

我正在尝试将nightwatch与独立的selenium一起使用(不需要通过nightwatch手动启动selenium )。我想在不打开浏览器的情况下运行它。这是我的配置

代码语言:javascript
复制
  output_folder: 'test/reports',
  custom_assertions_path: '',
  page_objects_path: "test/page-objects",

  selenium: {
    start_process: false,
  },

  test_settings: {
    default: {
      launch_url : 'http://localhost/dist',
      selenium_port: 4446,
      selenium_host: "xxx.xxx.xx.xx",
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions : {
          args : ["--no-sandbox"]
        },
      },
    }
  },

但这不是定位元素,测试失败。但是,如果我更改配置以启动selenium服务器并使用chrome运行,如下面的配置所示,它将完美地工作。

代码语言:javascript
复制
selenium: {
start_process: true,
server_path: seleniumServerPath,
cli_args: {  
  'webdriver.chrome.driver': chromedriverPath,
 },
},

test_settings: {
  default: {
    launch_url : 'http://localhost/dist',
    desiredCapabilities: {
      browserName: 'chrome',
    },
  }
},

我遗漏了什么?我希望它在gitlab runner中运行。

EN

回答 1

Stack Overflow用户

发布于 2018-12-04 12:32:48

找到了解决方案。它使用以下配置工作

代码语言:javascript
复制
"selenium": {
    "start_process": false,
    "server_path": seleniumServerPath,
    "cli_args": {  
      'webdriver.chrome.driver': chromedriverPath,
    },
  },

  "test_settings" : {
    "default" : {
      "launch_url" : 'http://xxx.xxx.xxx.xx:8000',
      "selenium_port"  : 4446,
      "selenium_host"  : "xxx.xxx.xxx.xx",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "on_failure" : true,
        "on_error" : false,
        "path" : "tmp/screenshots"
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
          "args" : ["--no-sandbox"]
        },
        "acceptSslCerts": true
      }
    },
  },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53594841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档