通过Nightwatch整合Travis-CI和SauceLabs失败

时间:2016-02-16 23:23:44

标签: travis-ci saucelabs nightwatch.js

我正在使用Nightwatch.js进行e2e测试。所有配置都已针对本地selenium服务器以及酱料实验室云服务器进行了本地测试。然而,当travis-ci通过酱汁连接运行相同的酱汁实验室配置时,它失败了。双方似乎最初正确参与,但是selenium命令似乎没有到达在travis中http://localhost:3000运行的测试服务器。我相信通过将等待时间增加到30秒,我已经排除了任何延迟问题。以下是双方的一些日志。我忽略了什么?

1)Travis日志显示酱油连接成功建立安全隧道: Extracting Sauce Connect Waiting for Sauce Connect readyfile 16 Feb 03:15:38 - Sauce Connect 4.3.13, build 1877 d9e5947 16 Feb 03:15:38 - Using CA certificate bundle /etc/ssl/certs/ca-certificates.crt. 16 Feb 03:15:38 - Using CA certificate verify path /etc/ssl/certs. 16 Feb 03:15:38 - Starting up; pid 4428 16 Feb 03:15:38 - Command line arguments: sc-4.3.13-linux//bin/sc -i 3101.1 -f sauce-connect-ready-15989 -l /home/travis/sauce-connect.log 16 Feb 03:15:38 - Using no proxy for connecting to Sauce Labs REST API. 16 Feb 03:15:38 - Resolving saucelabs.com to 162.222.75.243 took 13 ms. 16 Feb 03:15:38 - Started scproxy on port 59947. 16 Feb 03:15:38 - Please wait for 'you may start your tests' to start your tests. 16 Feb 03:15:38 - Starting secure remote tunnel VM... 16 Feb 03:15:41 - Secure remote tunnel VM provisioned. 16 Feb 03:15:41 - Tunnel ID: bd1ca94199724fddb1700dfa648706de 16 Feb 03:15:42 - Secure remote tunnel VM is now: booting 16 Feb 03:15:44 - Secure remote tunnel VM is now: running 16 Feb 03:15:44 - Using no proxy for connecting to tunnel VM. 16 Feb 03:15:44 - Resolving tunnel hostname to 162.222.75.26 took 311ms. 16 Feb 03:15:44 - Starting Selenium listener... 16 Feb 03:15:44 - Establishing secure TLS connection to tunnel... 16 Feb 03:15:45 - Selenium listener started on port 4445. 16 Feb 03:15:57 - Sauce Connect is up, you may start your tests.

2)Travis Logs显示本地测试应用服务器(e2e)正确启动(它绑定到localhost:3000):

```

KeystoneJS已开始:

e2e已准备好在端口3000上

```

3)Travis日志显示测试开始然后超时:

[Group001登录/ Test001具有登录视图]测试套件

正在运行:Keystone应该有一个登录视图

等待元素存在30000毫秒时超时。 - 期望“可见”但得到:在Object.module.exports.Keystone找不到应该有一个登录视图FAILED:1断言失败(37.752s)

4)另一方面酱实验室显示:

20:10:21.795 INFO - Launching a standalone Selenium Server
Setting system property webdriver.firefox.logfile to /home/chef/log/firefox.log
Setting system property webdriver.server.session.timeout to 0
20:10:21.848 INFO - Java: Oracle Corporation 25.72-b15
20:10:21.849 INFO - OS: Linux 3.13.0-32-generic i386
20:10:21.862 INFO - v2.48.0, with Core v2.48.0. Built from revision b7b081a
20:10:21.954 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
20:10:21.955 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
20:10:21.955 INFO - Driver class not found: com.opera.core.systems.OperaDriver
20:10:21.955 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
20:10:22.064 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4443/wd/hub
20:10:22.064 INFO - Selenium Server is up and running
20:10:22.287 INFO - Executing: [new session: Capabilities [{acceptSslCerts=true, webdriver.remote.quietExceptions=true, browserName=firefox, javascriptEnabled=true}]])
20:10:22.311 INFO - Creating a new session for Capabilities [{acceptSslCerts=true, webdriver.remote.quietExceptions=true, browserName=firefox, javascriptEnabled=true}]
20:10:25.435 INFO - Done: [new session: Capabilities [{acceptSslCerts=true, webdriver.remote.quietExceptions=true, browserName=firefox, javascriptEnabled=true}]]
20:10:25.842 INFO - Executing: [execute script: return screen.width, []])
20:10:25.949 INFO - Done: [execute script: return screen.width, []]
20:10:25.955 INFO - Executing: [execute script: return screen.height, []])
20:10:26.293 INFO - Done: [execute script: return screen.height, []]
20:10:26.300 INFO - Executing: [set window position])
20:10:26.314 INFO - Done: [set window position]
20:10:26.322 INFO - Executing: [set window size])
20:10:26.374 INFO - Done: [set window size]
20:10:26.378 INFO - Executing: [maximise window])
20:10:26.387 INFO - Done: [maximise window]
20:10:26.391 INFO - Executing: [get window handles])
20:10:26.399 INFO - Done: [get window handles]
20:10:28.944 INFO - Executing: [get: http://localhost:3000/keystone])
20:10:29.015 INFO - Done: [get: http://localhost:3000/keystone]
20:10:29.527 INFO - Executing: [find elements: By.cssSelector: div#signin-view])
20:10:29.536 INFO - Done: [find elements: By.cssSelector: div#signin-view]
20:10:30.031 INFO - Executing: [find elements: By.cssSelector: div#signin-view])
20:10:30.040 INFO - Done: [find elements: By.cssSelector: div#signin-view]
20:10:30.897 INFO - Executing: [find elements: By.cssSelector: div#signin-view])
20:10:30.906 INFO - Done: [find elements: By.cssSelector: div#signin-view]
20:10:31.404 INFO - Executing: [find elements: By.cssSelector: div#signin-view])
20:10:31.413 INFO - Done: [find elements: By.cssSelector: div#signin-view]
...<REPEATS UNTIL TIMEOUT>

5)Nightwatch酱实验室配置如下所示: "saucelabs" : { "selenium_host" : "ondemand.saucelabs.com", "selenium_port" : 80, "username" : "${SAUCE_USERNAME}", "access_key" : "${SAUCE_ACCESS_KEY}", "use_ssl" : false, "silent" : true, "output" : true, "screenshots" : { "enabled" : false, "on_failure" : true, "path" : "" }, "desiredCapabilities": { "name" : "test-firefox", "browserName" : "firefox", }, "selenium" : { "start_process" : false } },

1 个答案:

答案 0 :(得分:1)

为了其他人遇到同样的问题,这个特定问题的解决方案是添加隧道标识符,如:

     "desiredCapabilities": {
    "name": "test-firefox",
    "browserName": "firefox",
    "tunnel-identifier": "${TRAVIS_JOB_NUMBER}"
  }