量角器在加载页面后立即重定向并超时
Protractor redirects and times out immediately after loading page
我正在尝试为 AngularJS 应用程序编写一些 e2e 规范。我在 test/e2e/test_spec.js
:
中有一个 Jasmine 规范
describe('basic functionality', function() {
it('loads the home page', function() {
browser.get('/');
expect(browser.getCurrentUrl()).toMatch(/localhost/);
});
});
规格为运行时的终端输出:
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
Error: waiting for page to load for 10000ms
Wait timed out after 10013ms
Stacktrace:
Error: waiting for page to load for 10000ms
Wait timed out after 10013ms
at Array.forEach (native)
From: Task: waiting for page to load for 10000ms
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:3:13)
From: Task: Asynchronous test function: it()
Error
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:2:3)
at Object.<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:1:63)
Finished in 10.955 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
当控制台位于 [launcher] Running 1 instances of WebDriver
时,Chrome 打开并显示索引页面几分之一秒,然后变为空白页面,地址为 data:text/html,<html></html>
酒吧.
这是我的 protractor.config.js
:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: 'test/e2e/**/*_spec.js',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true
},
allScriptsTimeout: 20000,
onPrepare: function() {
return browser.driver.get("http://localhost:8100");
}
};
我的 webdriver-manager 似乎是最新的,尽管该工具似乎无法输出版本号。
> webdriver-manager status
selenium standalone is up to date
chromedriver is up to date
IEDriver is not present
为什么规范失败了?
编辑: 这是 onPrepare
被注释掉时打印到终端的内容:
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
unknown
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
timeout: timed out after 30000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 34.27 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
编辑 2: 当我执行 browser.get("http://google.com")
时,Chrome 会短暂显示 data:
和 data:text/html,<html></html>
页面,重定向到Google,然后查找 Angular 超时。
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
Error: Angular could not be found on the page http://google.com/ : retries looking for angular exceeded
Stacktrace:
Error: Angular could not be found on the page http://google.com/ : retries looking for angular exceeded
at Array.forEach (native)
From: Task: Asynchronous test function: it()
Error
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:2:3)
at Object.<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:1:63)
Finished in 12.186 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
在您的 protractor.config.js
文件中设置 baseUrl: 'http://localhost:8100'
。来自 Protractor Reference Config:
A base URL for your application under test. Calls to protractor.get() with relative paths will be prepended with this.
量角器零星开放的bug https://github.com/angular/protractor/issues/5103
而不是这个
browser.get('http://juliemr.github.io/protractor-demo/');
使用它解决了我的问题。
browser.driver.get('http://juliemr.github.io/protractor-demo/');
我在 chrome 中遇到了这个问题。我在某处读到量角器从 data:text/html,<html></html>
页面开始。调用 browser.get(...)
离开该页面。我的想法是在我的基地 url 上打开 chrome。我通过将它添加到这样的功能来实现这一点:
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['--app=www.yourBaseUrl.com']
}
},
有点乱,但似乎已经成功了。
我正在尝试为 AngularJS 应用程序编写一些 e2e 规范。我在 test/e2e/test_spec.js
:
describe('basic functionality', function() {
it('loads the home page', function() {
browser.get('/');
expect(browser.getCurrentUrl()).toMatch(/localhost/);
});
});
规格为运行时的终端输出:
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
Error: waiting for page to load for 10000ms
Wait timed out after 10013ms
Stacktrace:
Error: waiting for page to load for 10000ms
Wait timed out after 10013ms
at Array.forEach (native)
From: Task: waiting for page to load for 10000ms
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:3:13)
From: Task: Asynchronous test function: it()
Error
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:2:3)
at Object.<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:1:63)
Finished in 10.955 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
当控制台位于 [launcher] Running 1 instances of WebDriver
时,Chrome 打开并显示索引页面几分之一秒,然后变为空白页面,地址为 data:text/html,<html></html>
酒吧.
这是我的 protractor.config.js
:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: 'test/e2e/**/*_spec.js',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true
},
allScriptsTimeout: 20000,
onPrepare: function() {
return browser.driver.get("http://localhost:8100");
}
};
我的 webdriver-manager 似乎是最新的,尽管该工具似乎无法输出版本号。
> webdriver-manager status
selenium standalone is up to date
chromedriver is up to date
IEDriver is not present
为什么规范失败了?
编辑: 这是 onPrepare
被注释掉时打印到终端的内容:
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
unknown
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
timeout: timed out after 30000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 34.27 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
编辑 2: 当我执行 browser.get("http://google.com")
时,Chrome 会短暂显示 data:
和 data:text/html,<html></html>
页面,重定向到Google,然后查找 Angular 超时。
> protractor protractor.config.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
basic functionality
loads the home page - fail
Failures:
1) basic functionality loads the home page
Message:
Error: Angular could not be found on the page http://google.com/ : retries looking for angular exceeded
Stacktrace:
Error: Angular could not be found on the page http://google.com/ : retries looking for angular exceeded
at Array.forEach (native)
From: Task: Asynchronous test function: it()
Error
at [object Object].<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:2:3)
at Object.<anonymous> (/Users/jdent/swamp-bunny/test/e2e/test_spec.js:1:63)
Finished in 12.186 seconds
1 test, 1 assertion, 1 failure
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
在您的 protractor.config.js
文件中设置 baseUrl: 'http://localhost:8100'
。来自 Protractor Reference Config:
A base URL for your application under test. Calls to protractor.get() with relative paths will be prepended with this.
量角器零星开放的bug https://github.com/angular/protractor/issues/5103
而不是这个
browser.get('http://juliemr.github.io/protractor-demo/');
使用它解决了我的问题。
browser.driver.get('http://juliemr.github.io/protractor-demo/');
我在 chrome 中遇到了这个问题。我在某处读到量角器从 data:text/html,<html></html>
页面开始。调用 browser.get(...)
离开该页面。我的想法是在我的基地 url 上打开 chrome。我通过将它添加到这样的功能来实现这一点:
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['--app=www.yourBaseUrl.com']
}
},
有点乱,但似乎已经成功了。