'Angular could not be found' 集成 Travis/Sauce 实验室时
'Angular could not be found' when integrating Travis/Sauce Labs
我正在努力让 Travis CI 到 运行 使用 Sauce Labs 进行 Protractor 测试。隧道工作正常,我的 Express 服务器明显启动并保持在 http://localhost:9000
,但我的 Protractor 测试很快失败并显示错误 Error: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded
。 Internet 上的所有建议通常涉及不使用 Angular 1.0(使用 1.3)、延长超时时间(这样做)或强制 Protractor 查看 <html>
以获取 ng-app 指令(这样做那)。我没主意了。
相关配置:
protractor.conf.js
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
baseUrl: 'http://localhost:9000',
specs: ['e2e/**/*.spec.js'],
framework: 'jasmine',
maxSessions: 1,
allScriptsTimeout: 30000,
rootElement: 'html',
multiCapabilities: [
{'browserName': 'chrome'},
{'browserName': 'firefox'},
{'name': 'diplomacy'},
{'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER ? process.env.TRAVIS_JOB_NUMBER : null},
{'build': process.env.TRAVIS_BUILD_NUMBER ? process.env.TRAVIS_BUILD_NUMBER : null}
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 360000,
includeStackTrace: true
}
}
main.spec.js
'use strict';
describe('Home page', function() {
var page;
beforeEach(function() {
browser.get(browser.baseUrl);
});
it('should pass', function() {
expect(true).toBe(true);
});
});
特拉维斯日志
转到 here 以获得完整的日志。亮点:
Extracting Sauce Connect
Waiting for Sauce Connect readyfile
08 Mar 16:30:00 - Sauce Connect 4.3.6, build 1628 8a5c837
08 Mar 16:30:00 - Using CA certificate bundle /etc/ssl/certs/ca-certificates.crt.
08 Mar 16:30:00 - Starting up; pid 3519
08 Mar 16:30:00 - Command line arguments: sc-4.3.6-linux//bin/sc -i 42.1 -f sauce-connect-ready-21801 -l /home/travis/sauce-connect.log
08 Mar 16:30:00 - Using no proxy for connecting to Sauce Labs REST API.
08 Mar 16:30:00 - Resolving saucelabs.com to 162.222.73.28 took 17 ms.
08 Mar 16:30:01 - Started scproxy on port 37246.
08 Mar 16:30:01 - Please wait for 'you may start your tests' to start your tests.
08 Mar 16:30:01 - Starting secure remote tunnel VM...
08 Mar 16:30:11 - Secure remote tunnel VM provisioned.
08 Mar 16:30:11 - Tunnel ID: 3cc5fd5b59984957831d125617c7d4f6
08 Mar 16:30:11 - Secure remote tunnel VM is now: booting
08 Mar 16:30:14 - Secure remote tunnel VM is now: running
08 Mar 16:30:14 - Remote tunnel host is: maki76159.miso.saucelabs.com
08 Mar 16:30:14 - Using no proxy for connecting to tunnel VM.
08 Mar 16:30:14 - Resolving maki76159.miso.saucelabs.com to 162.222.76.159 took 48 ms.
08 Mar 16:30:14 - Starting Selenium listener...
08 Mar 16:30:14 - Establishing secure TLS connection to tunnel...
08 Mar 16:30:14 - Selenium listener started on port 4445.
08 Mar 16:30:16 - Sauce Connect is up, you may start your tests.
08 Mar 16:30:16 - Connection established.
[此处进行单元测试...全部通过!]
[chrome #1] PID: 3621
[chrome #1] Specs: /home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js
[chrome #1]
[chrome #1] Using SauceLabs selenium server at http://ondemand.saucelabs.com:80/wd/hub
[chrome #1] [31mF[0m
[chrome #1]
[chrome #1] Failures:
[chrome #1]
[chrome #1] 1) Home page should pass
[chrome #1] Message:
[chrome #1] [31mError: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded[0m
[chrome #1] Stacktrace:
[chrome #1] Error: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded
[chrome #1] ==== async task ====
[chrome #1] Protractor.get(http://localhost:9000/) - test for angular
[chrome #1] at [object Object].<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:7:13)
[chrome #1] ==== async task ====
[chrome #1] Asynchronous test function: beforeEach()
[chrome #1] Error
[chrome #1] at [object Object].<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:6:3)
[chrome #1] at Object.<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:3:1)
[chrome #1]
[chrome #1] Finished in 11.877 seconds
[chrome #1] [31m1 test, 2 assertions, 1 failure
[0m[chrome #1]
[chrome #1] SauceLabs results available at http://saucelabs.com/jobs/c0eed61d95044f77b200a7b21d2443a3
[launcher] 1 instance(s) of WebDriver still running
[另外两个 WebDriver 实例因类似错误而失败]
FWIW,我最终让一切正常工作。没有 'one fix' 我做的所以我不能很容易地澄清解决方案。以下文件是 from my repository with which I set up continuous integration.
量角器-travis.conf.js
exports.config = {
// sauce plz
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
baseUrl: 'http://localhost',
specs: ['e2e/**/*.po.js', 'e2e/**/*.spec.js'],
framework: 'jasmine',
maxSessions: 1,
allScriptsTimeout: 40000,
getPageTimeout: 40000,
rootElement: 'html',
multiCapabilities: [
capabilitiesForBrowser('chrome', '41'),
capabilitiesForBrowser('firefox'),
capabilitiesForBrowser('safari')
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 360000,
includeStackTrace: true
}
};
function capabilitiesForBrowser(browserName, browserVersion) {
var capabilities = {
'browserName': browserName,
'build': process.env.TRAVIS_BUILD_NUMBER,
'name': 'dipl.io'
};
if (browserVersion)
capabilities.version = browserVersion;
return capabilities;
}
Gruntfile.js
protractor: {
travis: {
options: {
configFile: 'protractor-travis.conf.js',
args: {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY
}
}
},
local: {
options: {
configFile: 'protractor-local.conf.js'
//,debug: true
}
}
}
.travis.yml
language: node_js
node_js:
- '0.12'
services:
- mongodb
env:
global:
- secure: ioYHs4gjuL9iuwxamtKCkERvvSiBlAgxhLZ1Ry4xrZhNWe3e4pett3249hWovDYzG/eEHTA20/NDvZ1JIMYODFzY4gURVHNtUkoYNokLSDguTH1OPXGMmtQzJGersxYQOjRj3gSss7Z0joUrcfPQJsG1Vt0eHR/ewN7Qbm8NBn0=
- secure: NH3WbHM2Ir95csdWAdd7/ISYVvnYFQe7Rv4rCoYu9V6V2M9AzlARYTAvBqoK7PdD/RV0KR41t6OVeUxBVhuzT26NvBVZVyLcvfjK29AoKCDCU7VD7nQa/RQ9KyDr5DAHfyQQ5AQMhsla5qPTaFZb82F83lL44nDzrvYzE8CEaGw=
before_install:
- npm install -g bower
- bower install
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
- npm install -g grunt-cli
script:
- grunt test:protractor-travis
我遇到了同样的问题。除了这里有一个区别:
当我手动启动 SauceConnect 隧道时,如下所述:
https://docs.saucelabs.com/reference/sauce-connect/#when-should-i-use-sauce-connect-
然后一切顺利,我的构建通过。
但我不想每次都手动启动 SauceConnect,我希望它在构建过程中自动发生。所以我按照此处的说明更新了 travis.yml 文件:
http://docs.travis-ci.com/user/sauce-connect/
在这种情况下,隧道自动打开。这里有一些日志,太长无法全部粘贴,但我可以向您保证隧道已打开。
Starting Sauce Connect
25.96s$ travis_start_sauce_connect
Using temp dir /tmp/sc.hHct
/tmp/sc.hHct ~/build/Diobox/diobox_stateful
Downloading Sauce Connect
--2015-06-11 17:13:21-- http://saucelabs.com/downloads/sc-4.3.6-linux.tar.gz
Resolving saucelabs.com (saucelabs.com)... 162.222.73.28
Connecting to saucelabs.com (saucelabs.com)|162.222.73.28|:80... connected.
HTTP request sent, awaiting response... 200 OK
.....
11 Jun 17:13:23 - Starting up; pid 3524
11 Jun 17:13:23 - Command line arguments: sc-4.3.6-linux//bin/sc -i 25.1 -f sauce-connect-ready-29337 -l /home/travis/sauce-connect.log
11 Jun 17:13:23 - Using no proxy for connecting to Sauce Labs REST API.
11 Jun 17:13:23 - Resolving saucelabs.com to 162.222.73.28 took 1 ms.
11 Jun 17:13:24 - ***********************************************************
11 Jun 17:13:24 - A newer version of Sauce Connect (build 1671) is available!
11 Jun 17:13:24 - Download it here:
11 Jun 17:13:24 - https://saucelabs.com/downloads/sc-4.3.8-linux.tar.gz
11 Jun 17:13:24 - ***********************************************************
11 Jun 17:13:24 - Started scproxy on port 50965.
11 Jun 17:13:24 - Please wait for 'you may start your tests' to start your tests.
11 Jun 17:13:24 - Starting secure remote tunnel VM...
11 Jun 17:13:24 - Shutting down named tunnel 25.1 (b7f004bfd8174ac6be612082b1654367).
11 Jun 17:13:32 - Secure remote tunnel VM provisioned.
11 Jun 17:13:32 - Tunnel ID: 6f295a34dfe14b639b78438e59307ae3
11 Jun 17:13:32 - Secure remote tunnel VM is now: booting
11 Jun 17:13:46 - Secure remote tunnel VM is now: running
11 Jun 17:13:46 - Remote tunnel host is: maki78107.miso.saucelabs.com
11 Jun 17:13:46 - Using no proxy for connecting to tunnel VM.
11 Jun 17:13:46 - Resolving maki78107.miso.saucelabs.com to 162.222.78.107 took 8 ms.
11 Jun 17:13:46 - Starting Selenium listener...
11 Jun 17:13:46 - Establishing secure TLS connection to tunnel...
11 Jun 17:13:46 - Selenium listener started on port 4445.
11 Jun 17:13:47 - Sauce Connect is up, you may start your tests.
11 Jun 17:13:47 - Connection established.
但是,一旦打开连接,并且构建达到了应该进行测试的程度 运行,我就会遇到上面列出的相同 Angular 错误。
我正在努力让 Travis CI 到 运行 使用 Sauce Labs 进行 Protractor 测试。隧道工作正常,我的 Express 服务器明显启动并保持在 http://localhost:9000
,但我的 Protractor 测试很快失败并显示错误 Error: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded
。 Internet 上的所有建议通常涉及不使用 Angular 1.0(使用 1.3)、延长超时时间(这样做)或强制 Protractor 查看 <html>
以获取 ng-app 指令(这样做那)。我没主意了。
相关配置:
protractor.conf.js
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
baseUrl: 'http://localhost:9000',
specs: ['e2e/**/*.spec.js'],
framework: 'jasmine',
maxSessions: 1,
allScriptsTimeout: 30000,
rootElement: 'html',
multiCapabilities: [
{'browserName': 'chrome'},
{'browserName': 'firefox'},
{'name': 'diplomacy'},
{'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER ? process.env.TRAVIS_JOB_NUMBER : null},
{'build': process.env.TRAVIS_BUILD_NUMBER ? process.env.TRAVIS_BUILD_NUMBER : null}
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 360000,
includeStackTrace: true
}
}
main.spec.js
'use strict';
describe('Home page', function() {
var page;
beforeEach(function() {
browser.get(browser.baseUrl);
});
it('should pass', function() {
expect(true).toBe(true);
});
});
特拉维斯日志
转到 here 以获得完整的日志。亮点:
Extracting Sauce Connect
Waiting for Sauce Connect readyfile
08 Mar 16:30:00 - Sauce Connect 4.3.6, build 1628 8a5c837
08 Mar 16:30:00 - Using CA certificate bundle /etc/ssl/certs/ca-certificates.crt.
08 Mar 16:30:00 - Starting up; pid 3519
08 Mar 16:30:00 - Command line arguments: sc-4.3.6-linux//bin/sc -i 42.1 -f sauce-connect-ready-21801 -l /home/travis/sauce-connect.log
08 Mar 16:30:00 - Using no proxy for connecting to Sauce Labs REST API.
08 Mar 16:30:00 - Resolving saucelabs.com to 162.222.73.28 took 17 ms.
08 Mar 16:30:01 - Started scproxy on port 37246.
08 Mar 16:30:01 - Please wait for 'you may start your tests' to start your tests.
08 Mar 16:30:01 - Starting secure remote tunnel VM...
08 Mar 16:30:11 - Secure remote tunnel VM provisioned.
08 Mar 16:30:11 - Tunnel ID: 3cc5fd5b59984957831d125617c7d4f6
08 Mar 16:30:11 - Secure remote tunnel VM is now: booting
08 Mar 16:30:14 - Secure remote tunnel VM is now: running
08 Mar 16:30:14 - Remote tunnel host is: maki76159.miso.saucelabs.com
08 Mar 16:30:14 - Using no proxy for connecting to tunnel VM.
08 Mar 16:30:14 - Resolving maki76159.miso.saucelabs.com to 162.222.76.159 took 48 ms.
08 Mar 16:30:14 - Starting Selenium listener...
08 Mar 16:30:14 - Establishing secure TLS connection to tunnel...
08 Mar 16:30:14 - Selenium listener started on port 4445.
08 Mar 16:30:16 - Sauce Connect is up, you may start your tests.
08 Mar 16:30:16 - Connection established.
[此处进行单元测试...全部通过!]
[chrome #1] PID: 3621
[chrome #1] Specs: /home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js
[chrome #1]
[chrome #1] Using SauceLabs selenium server at http://ondemand.saucelabs.com:80/wd/hub
[chrome #1] [31mF[0m
[chrome #1]
[chrome #1] Failures:
[chrome #1]
[chrome #1] 1) Home page should pass
[chrome #1] Message:
[chrome #1] [31mError: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded[0m
[chrome #1] Stacktrace:
[chrome #1] Error: Angular could not be found on the page http://localhost:9000/ : retries looking for angular exceeded
[chrome #1] ==== async task ====
[chrome #1] Protractor.get(http://localhost:9000/) - test for angular
[chrome #1] at [object Object].<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:7:13)
[chrome #1] ==== async task ====
[chrome #1] Asynchronous test function: beforeEach()
[chrome #1] Error
[chrome #1] at [object Object].<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:6:3)
[chrome #1] at Object.<anonymous> (/home/travis/build/spamguy/diplomacy/e2e/main/main.spec.js:3:1)
[chrome #1]
[chrome #1] Finished in 11.877 seconds
[chrome #1] [31m1 test, 2 assertions, 1 failure
[0m[chrome #1]
[chrome #1] SauceLabs results available at http://saucelabs.com/jobs/c0eed61d95044f77b200a7b21d2443a3
[launcher] 1 instance(s) of WebDriver still running
[另外两个 WebDriver 实例因类似错误而失败]
FWIW,我最终让一切正常工作。没有 'one fix' 我做的所以我不能很容易地澄清解决方案。以下文件是 from my repository with which I set up continuous integration.
量角器-travis.conf.js
exports.config = {
// sauce plz
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
baseUrl: 'http://localhost',
specs: ['e2e/**/*.po.js', 'e2e/**/*.spec.js'],
framework: 'jasmine',
maxSessions: 1,
allScriptsTimeout: 40000,
getPageTimeout: 40000,
rootElement: 'html',
multiCapabilities: [
capabilitiesForBrowser('chrome', '41'),
capabilitiesForBrowser('firefox'),
capabilitiesForBrowser('safari')
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 360000,
includeStackTrace: true
}
};
function capabilitiesForBrowser(browserName, browserVersion) {
var capabilities = {
'browserName': browserName,
'build': process.env.TRAVIS_BUILD_NUMBER,
'name': 'dipl.io'
};
if (browserVersion)
capabilities.version = browserVersion;
return capabilities;
}
Gruntfile.js
protractor: {
travis: {
options: {
configFile: 'protractor-travis.conf.js',
args: {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY
}
}
},
local: {
options: {
configFile: 'protractor-local.conf.js'
//,debug: true
}
}
}
.travis.yml
language: node_js
node_js:
- '0.12'
services:
- mongodb
env:
global:
- secure: ioYHs4gjuL9iuwxamtKCkERvvSiBlAgxhLZ1Ry4xrZhNWe3e4pett3249hWovDYzG/eEHTA20/NDvZ1JIMYODFzY4gURVHNtUkoYNokLSDguTH1OPXGMmtQzJGersxYQOjRj3gSss7Z0joUrcfPQJsG1Vt0eHR/ewN7Qbm8NBn0=
- secure: NH3WbHM2Ir95csdWAdd7/ISYVvnYFQe7Rv4rCoYu9V6V2M9AzlARYTAvBqoK7PdD/RV0KR41t6OVeUxBVhuzT26NvBVZVyLcvfjK29AoKCDCU7VD7nQa/RQ9KyDr5DAHfyQQ5AQMhsla5qPTaFZb82F83lL44nDzrvYzE8CEaGw=
before_install:
- npm install -g bower
- bower install
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
- npm install -g grunt-cli
script:
- grunt test:protractor-travis
我遇到了同样的问题。除了这里有一个区别:
当我手动启动 SauceConnect 隧道时,如下所述: https://docs.saucelabs.com/reference/sauce-connect/#when-should-i-use-sauce-connect-
然后一切顺利,我的构建通过。
但我不想每次都手动启动 SauceConnect,我希望它在构建过程中自动发生。所以我按照此处的说明更新了 travis.yml 文件:
http://docs.travis-ci.com/user/sauce-connect/
在这种情况下,隧道自动打开。这里有一些日志,太长无法全部粘贴,但我可以向您保证隧道已打开。
Starting Sauce Connect
25.96s$ travis_start_sauce_connect
Using temp dir /tmp/sc.hHct
/tmp/sc.hHct ~/build/Diobox/diobox_stateful
Downloading Sauce Connect
--2015-06-11 17:13:21-- http://saucelabs.com/downloads/sc-4.3.6-linux.tar.gz
Resolving saucelabs.com (saucelabs.com)... 162.222.73.28
Connecting to saucelabs.com (saucelabs.com)|162.222.73.28|:80... connected.
HTTP request sent, awaiting response... 200 OK
.....
11 Jun 17:13:23 - Starting up; pid 3524
11 Jun 17:13:23 - Command line arguments: sc-4.3.6-linux//bin/sc -i 25.1 -f sauce-connect-ready-29337 -l /home/travis/sauce-connect.log
11 Jun 17:13:23 - Using no proxy for connecting to Sauce Labs REST API.
11 Jun 17:13:23 - Resolving saucelabs.com to 162.222.73.28 took 1 ms.
11 Jun 17:13:24 - ***********************************************************
11 Jun 17:13:24 - A newer version of Sauce Connect (build 1671) is available!
11 Jun 17:13:24 - Download it here:
11 Jun 17:13:24 - https://saucelabs.com/downloads/sc-4.3.8-linux.tar.gz
11 Jun 17:13:24 - ***********************************************************
11 Jun 17:13:24 - Started scproxy on port 50965.
11 Jun 17:13:24 - Please wait for 'you may start your tests' to start your tests.
11 Jun 17:13:24 - Starting secure remote tunnel VM...
11 Jun 17:13:24 - Shutting down named tunnel 25.1 (b7f004bfd8174ac6be612082b1654367).
11 Jun 17:13:32 - Secure remote tunnel VM provisioned.
11 Jun 17:13:32 - Tunnel ID: 6f295a34dfe14b639b78438e59307ae3
11 Jun 17:13:32 - Secure remote tunnel VM is now: booting
11 Jun 17:13:46 - Secure remote tunnel VM is now: running
11 Jun 17:13:46 - Remote tunnel host is: maki78107.miso.saucelabs.com
11 Jun 17:13:46 - Using no proxy for connecting to tunnel VM.
11 Jun 17:13:46 - Resolving maki78107.miso.saucelabs.com to 162.222.78.107 took 8 ms.
11 Jun 17:13:46 - Starting Selenium listener...
11 Jun 17:13:46 - Establishing secure TLS connection to tunnel...
11 Jun 17:13:46 - Selenium listener started on port 4445.
11 Jun 17:13:47 - Sauce Connect is up, you may start your tests.
11 Jun 17:13:47 - Connection established.
但是,一旦打开连接,并且构建达到了应该进行测试的程度 运行,我就会遇到上面列出的相同 Angular 错误。