【问题标题】:Run Nightwatch.js tests against a remote Selenium server in Kubernetes environment在 Kubernetes 环境中针对远程 Selenium 服务器运行 Nightwatch.js 测试
【发布时间】:2018-03-01 04:03:33
【问题描述】:

我已经基于Nightwatch.js 使用Nightwatch-Cucumber 创建了自动化测试。我可以在本地机器上启动测试,Selenium server 在本地机器上启动并执行测试。

但现在我想将现有测试集成到 Kubernetes 环境中。在本地机器上,我想使用minikubehelmjenkins chart 来启动测试和selenium chart。但是这种设置与本地设置不同。我想在Jenkins 实例上开始测试,并且应该针对selenium chart 提供的正在运行的Selenium server 执行测试。所以我想用这样一个“远程”Selenium server。我不想使用在运行时启动的本地 Selenium server,但在 Kubernetes 环境中的某处仍然存在 Selenium server

但是如何配置我的nightwatch.conf.js 配置来实现那个场景呢?

我当前的配置如下:

const config = {
  output_folder: "reports",
  custom_commands_path: "commands",
  // custom_assertions_path: 'assertions',
  live_output: false,
  page_objects_path: "pageobjects",
  disable_colors: false,
  selenium: {
    start_process: true,
    server_path: seleniumServer.path,
    log_path: "",
    host: "127.0.0.1",
    port: 4444
  },
  test_settings: {
    default: {
      globals: {
        waitForConditionTimeout: 30000,
        waitForConditionPollInterval: 500
      },
      screenshots: {
        enabled: true,
        on_failure: true,
        path: "screenshots"
      },
      //launch_url: "http://localhost:8087",
      //selenium_port: 4444,
      //selenium_host: "127.0.0.1",
      desiredCapabilities: {
        browserName: "phantomjs",
        javascriptEnabled: true,
        acceptSslCerts: true,
        "phantomjs.binary.path": phantomjs.path
      }
    },

【问题讨论】:

    标签: node.js selenium jenkins kubernetes nightwatch.js


    【解决方案1】:

    第一步,确保您的远程 Selenium 服务器是可访问的(检查主机 IP 和端口) 其次,配置如下:

        const config = {
      output_folder: "reports",
      custom_commands_path: "commands",
      // custom_assertions_path: 'assertions',
      live_output: false,
      page_objects_path: "pageobjects",
      disable_colors: false,
      selenium: {
        start_process: false, // turn this off and comment all below config
    //    server_path: seleniumServer.path,
    //    log_path: "",
    //    host: "127.0.0.1",
    //    port: 4444
      },
      test_settings: {
        default: {
          globals: {
            waitForConditionTimeout: 30000,
            waitForConditionPollInterval: 500
          },
          screenshots: {
            enabled: true,
            on_failure: true,
            path: "screenshots"
          },
           launch_url: "http://localhost:8087",
           selenium_port: 4444, // provide your selenium port in 1st step
           selenium_host: "127.0.0.1", // provide your selenium address in 1st step 
          desiredCapabilities: {
            browserName: "phantomjs",
            javascriptEnabled: true,
            acceptSslCerts: true,
            "phantomjs.binary.path": phantomjs.path
          }
        },
    

    【讨论】:

      猜你喜欢
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 2017-08-07
      • 1970-01-01
      相关资源
      最近更新 更多