Reputation: 55
Node Version: v6.9.4
Protractor Version: 5.1.1
Angular Version: 1.2.28
Browser(s): Chrome:Version 58.0.3029.96 (64-bit) Chrome WebDriver:Version 2.29
Operating System and Version: MAC OS Siera 10.12.3
protractor configuration file
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
specs: ['./Test/LoginTest.js'],
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000
}
A relevant example test
There is button in the page, when i try to click using protractor , It throws time out error . Unable to click on the element. Same thing work on selenium webdriver.
Step to Reproduce
Step 1: Open website using this URL https://www.neonmob.com/login
Step 2: Enter the user name and password mentioned below and click on Login button
UserName: sharif33332
Password: 1234
Step 3: After login navigate to this URL https://www.neonmob.com/shariftestuser
to navigate to exact page where problem occurs.
Issue :Now at this page unable to click on Trade Button and it throws time out exception error.
Same element can be found using jQuery. Please follow the above steps to reproduce this issue.
Used the below code to click on this button
element(by.css("span[id='trade-btn']")).click();
Please let me know if you are not able to follow the steps. I believe there is an issue in protratcor
Upvotes: 1
Views: 1606
Reputation: 55
@wswebcreation , Are you sure this is not the angular page. If it is not then angular wait will not work. Will be needed to browser.ignoreSynchronization=true .
Anyway I will ask our developer to look onto this and debug it more to fix from application side.
Anyway current solution provided above working fine.
Thank you so much for your help
Upvotes: 0
Reputation: 517
After checking, your second URL (does not seem) to be an angular page and requires ignoreSynchronization.
Try using the code below:
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://www.neonmob.com/login');
element(by.id('field-username')).sendKeys('sharif33332');
element(by.id('field-password')).sendKeys('1234');
element(by.id('signin-btn')).click();
browser.waitForAngular();
browser.ignoreSynchronization=true
browser.executeScript('this.document.location = "https://www.neonmob.com/shariftestuser"');
element(by.id('trade-btn')).click();
});
});
I did not fix the format, you can do that one. :)
Nothing special on config as well, I only use this:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
jasmineNodeOpts: {defaultTimeoutInterval: 60000}
};
Upvotes: -1
Reputation: 2375
I found the problem. There is nothing wrong with protractor. There is something wrong with the page. You don't get a timeout on clicking on the button / not finding it. You get an error because the page times out because Angular didn't release the page. There are still open calls or what so ever that keep Angular not ready. This was the log I got
Failures:
1) click on trade button should click on the trade button
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
Message:
Failed: Timed out waiting for asynchronous Angular tasks to finish after 30 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(css selector, #trade-btn).
The following tasks were pending:
- $timeout: function (){ownershipPromise=artPieceService.syncOwnership()}
If you disable the wait for angular with this it will work
describe('click on trade button', () => {
beforeEach(function () {
browser.get(browser.baseUrl);
$('#field-username').sendKeys('sharif33332');
$('#field-password').sendKeys('1234');
$('#signin-btn').click();
browser.driver.wait(() => browser.getCurrentUrl().then((currentUrl) => currentUrl === 'https://www.neonmob.com/sharif33332'));
browser.get('https://www.neonmob.com/shariftestuser')
});
it('should click on the trade button', () => {
// Disable wait for Angular
browser.ignoreSynchronization = true;
// Wait 2 seconds for the page to be loaded
browser.sleep(2000)
$('#trade-btn').click();
// Wait to verify that the trade button has been clicked.
browser.sleep(5000);
})
});
This will confirm that there is nothing wrong with protractor but you need to dive into Angular on this page / ask a developer to fix this.
Upvotes: 1