first of all the versions I'm using:
protractor v5.1.2 chromedriver v2.33 node v6.11.4 npm 3.10.10 selenium-webdriver v3.0.1
I'm new to protractor and I'm only trying to run it on the test that is already given natively by protractor. It looks like this
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
describe('todo list', function() {
var todoList;
beforeEach(function() {
browser.get('http://www.angularjs.org');
todoList = element.all(by.repeater('todo in todoList.todos'));
});
it('should list todos', function() {
expect(todoList.count()).toEqual(2);
expect(todoList.get(1).getText()).toEqual('build an AngularJS app');
});
it('should add a todo', function() {
var addTodo = element(by.model('todoList.todoText'));
var addButton = element(by.css('[value="add"]'));
addTodo.sendKeys('write a protractor test');
addButton.click();
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
});
});
});
This right here is the conf.js
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['example_spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
When I try to run this it gives me the following error:
Failures:
1) angularjs homepage should greet the named user
Message:
Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: by.model("yourName")
Stack:
ScriptTimeoutError: asynchronous script timeout: result was not received in 11 seconds
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 3.16.0-4-amd64 x86_64)
at WebDriverError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at ScriptTimeoutError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:203:5)
at Object.checkLegacyResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: Protractor.waitForAngular() - Locator: by.model("yourName")
at Driver.schedule (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:816:17)
at ProtractorBrowser.executeAsyncScript_ (/usr/lib/node_modules/protractor/lib/browser.ts:609:24)
at angularAppRoot.then (/usr/lib/node_modules/protractor/lib/browser.ts:643:23)
at ManagedPromise.invokeCallback_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1366:14)
at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2813:27)
at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:676:7
at process._tickCallback (internal/process/next_tick.js:109:7)Error
at ElementArrayFinder.applyAction_ (/usr/lib/node_modules/protractor/lib/element.ts:482:23)
at ElementArrayFinder.(anonymous function) [as sendKeys] (/usr/lib/node_modules/protractor/lib/element.ts:96:21)
at ElementFinder.(anonymous function) [as sendKeys] (/usr/lib/node_modules/protractor/lib/element.ts:873:14)
at UserContext.<anonymous> (/home/kunstmann/Downloads/node-v6.11.4-linux-x64/lib/node_modules/npm/node_modules/protractor/example/example_spec.js:5:35)
at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:112:25
at new ManagedPromise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1067:7)
at ControlFlow.promise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2396:12)
at schedulerExecute (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:95:18)
at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2953:27)
From: Task: Run it("should greet the named user") in control flow
at UserContext.<anonymous> (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:19)
From asynchronous test:
Error
at Suite.<anonymous> (/home/kunstmann/Downloads/node-v6.11.4-linux-x64/lib/node_modules/npm/node_modules/protractor/example/example_spec.js:2:3)
at Object.<anonymous> (/home/kunstmann/Downloads/node-v6.11.4-linux-x64/lib/node_modules/npm/node_modules/protractor/example/example_spec.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
3 specs, 1 failure
Finished in 17.5 seconds
[11:34:30] I/launcher - 0 instance(s) of WebDriver still running
[11:34:30] I/launcher - chrome #01 failed 1 test(s)
[11:34:30] I/launcher - overall: 1 failed spec(s)
[11:34:30] E/launcher - Process exited with error code 1
As I said, I didn't write any of this. The code was provided by protractor itself in a folder called example. Now, however, I tried switching the test cases, because I didn't understand why the first one would fail. It looked perfectly right to me. And now here is what is strange. When I put a different test case on top the new one - that is now on top - will fail, but the one that was on top before won't have any problems anymore. I can do this with every single test case, the first case will always fail, but as soon as I move it away from the top, it suddenly works.
I already tried following the link in the error message, but it didn't do anything for me. Also I've updated everything a hundred times, but nothing changed.
Does anyboby know what this is? This is really strange...
答案 0 :(得分:1)
你需要告诉Protractor不要等待Angular $ http和$ timeout,就像这样:
旧的弃用方式:
browser.ignoreSynchronization = true;
新的正确方法:
browser.waitForAngularEnabled(false);
这有帮助吗?