【问题标题】:Running nightwatch.js tests on linux box?在 Linux 机器上运行 nightwatch.js 测试?
【发布时间】:2016-06-03 14:22:23
【问题描述】:

我正在尝试在安装了 Centos OS 的 linux 机器上运行 nightwatch 自动 ui 测试。我在开始时遇到了问题。

这是我在 nightwatch.json 中的 test_settings 配置

"test_settings": {
        "default": {
            "launch_url": "",
            "selenium_port": 4444,
            "selenium_host": "localhost",
            "silent": true,
            "screenshots": {
                "enabled": true,
                "on_failure": true,
                "on_error": true,
                "path": "./screenshots"
            },
            "detailed_option": true,
            "end_session_on_fail": false,
            "desiredCapabilities": {
                "browserName": "chrome",
                "javascriptEnabled": true,
                "acceptSslCerts": true,
                "chromeOptions": {
                    "args": [
                        "use-fake-device-for-media-stream",
                        "use-fake-ui-for-media-stream"
                    ]
                }
            }
        },

我安装了 linux 64bit chrome 驱动程序。然后我安装了 selenium 独立服务器。但是当我想要使用 node nightwatch 进行夜间测试时,我得到了一个错误

“连接被拒绝!Selenium 没有启动..”

如何设置一个 linux 机器来运行 nightwatch 自动化 UI 测试?

当我将 start_process 设置为 false 并单独运行 selenium 服务器时,我收到以下错误:

14:23:41.158 WARN - Exception: unknown error: Chrome failed to start: exited abnormally

【问题讨论】:

    标签: linux node.js selenium nightwatch.js


    【解决方案1】:

    您的 nightwatch.json 看起来缺少许多对象,特别是 selenium 服务器设置,这可以解释 "Connection is refused! Selenium not started.."。例如,这是我的,其中大部分将特定于您的环境:

    {
      "src_folders": ["./tests"],
      "output_folder": "reports",
      "custom_commands_path": [
        "./node_modules/testarmada-magellan-nightwatch/lib/commands",
        "./lib/custom_commands"
      ],
      "custom_assertions_path": [
        "./node_modules/testarmada-magellan-nightwatch/lib/assertions"
      ],
    
      "page_objects_path": [
        "./lib/pages"
      ],
    
      "selenium": {
        "start_process": true,
        "server_path": "./node_modules/testarmada-magellan-nightwatch/node_modules/selenium-server/lib/runner/selenium-server-standalone-2.52.0.jar",
        "log_path": "reports",
        "host": "127.0.0.1",
        "port": 4444,
        "cli_args": {
          "webdriver.chrome.driver": "./node_modules/testarmada-magellan-nightwatch/node_modules/chromedriver/lib/chromedriver/chromedriver",
          "webdriver.ie.driver": ""
        }
      },
    
      "test_settings": {
        "default": {
          "launch_url": "http://127.0.0.1",
          "selenium_port": 4444,
          "selenium_host": "localhost",
          "silent": true,
          "sync_test_names": true,
          "screenshots": {
            "enabled": false,
            "path": ""
          },
          "desiredCapabilities": {
            "browserName": "chrome"
          },
          "globals": {
            "waitForConditionTimeout": 60000
          }
        },
    
        "phantomjs": {
          "desiredCapabilities": {
            "browserName": "phantomjs",
            "javascriptEnabled": true,
            "acceptSslCerts": true,
            "phantomjs.binary.path": "./node_modules/testarmada-magellan-nightwatch/node_modules/phantomjs/bin/phantomjs"
          }
        },
    
        "safari": {
          "desiredCapabilities": {
            "browserName": "safari"
          }
        },
    
        "firefox": {
          "desiredCapabilities": {
            "browserName": "firefox"
          }
        },
    
        "chrome": {
          "desiredCapabilities": {
            "browserName": "chrome"
          }
        },
    
        "sauce": {
          "selenium_host": "ondemand.saucelabs.com",
          "selenium_port": 80,
          "username": "myUserName",
          "access_key": "",
          "desiredCapabilities": {
            "browserName": "${SAUCE_BROWSER_NAME}",
            "platform": "${SAUCE_BROWSER_PLATFORM}",
            "version": "${SAUCE_BROWSER_VERSION}",
            "tunnel-identifier": "${SAUCE_TUNNEL_ID}"
          },
          "selenium": {
            "start_process": false
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-03-02
      • 2019-09-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多