Protractor test hangs on await browser.wait with disabled control flow
We're writing e2e tests in async/await fashion to be able to debug them. But test that has
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
Just hangs on this line. I don't know why and I don't get it. It runs fine when control flow is enabled but as soon as we disable it, it starts hanging. The test case looks like this
it('should login', async () => {
await page.navigateTo();
await page.login();
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
await browser.waitForAngularEnabled(false);
expect(await browser.getCurrentUrl()).toContain('/login');
});
Idea is to wait for navigation to be complete after we login. In browser where I can see e2e execution it is clearly visible that it reached the right page and the logo is there, but it gets stuck there until timeout happens. Does anyone know why?
angular protractor angular-e2e
add a comment |
We're writing e2e tests in async/await fashion to be able to debug them. But test that has
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
Just hangs on this line. I don't know why and I don't get it. It runs fine when control flow is enabled but as soon as we disable it, it starts hanging. The test case looks like this
it('should login', async () => {
await page.navigateTo();
await page.login();
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
await browser.waitForAngularEnabled(false);
expect(await browser.getCurrentUrl()).toContain('/login');
});
Idea is to wait for navigation to be complete after we login. In browser where I can see e2e execution it is clearly visible that it reached the right page and the logo is there, but it gets stuck there until timeout happens. Does anyone know why?
angular protractor angular-e2e
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57
add a comment |
We're writing e2e tests in async/await fashion to be able to debug them. But test that has
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
Just hangs on this line. I don't know why and I don't get it. It runs fine when control flow is enabled but as soon as we disable it, it starts hanging. The test case looks like this
it('should login', async () => {
await page.navigateTo();
await page.login();
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
await browser.waitForAngularEnabled(false);
expect(await browser.getCurrentUrl()).toContain('/login');
});
Idea is to wait for navigation to be complete after we login. In browser where I can see e2e execution it is clearly visible that it reached the right page and the logo is there, but it gets stuck there until timeout happens. Does anyone know why?
angular protractor angular-e2e
We're writing e2e tests in async/await fashion to be able to debug them. But test that has
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
Just hangs on this line. I don't know why and I don't get it. It runs fine when control flow is enabled but as soon as we disable it, it starts hanging. The test case looks like this
it('should login', async () => {
await page.navigateTo();
await page.login();
await browser.wait(ExpectedConditions.presenceOf(appPage.getLogo()));
await browser.waitForAngularEnabled(false);
expect(await browser.getCurrentUrl()).toContain('/login');
});
Idea is to wait for navigation to be complete after we login. In browser where I can see e2e execution it is clearly visible that it reached the right page and the logo is there, but it gets stuck there until timeout happens. Does anyone know why?
angular protractor angular-e2e
angular protractor angular-e2e
asked Nov 23 '18 at 9:46
Blind DespairBlind Despair
136115
136115
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57
add a comment |
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57
add a comment |
1 Answer
1
active
oldest
votes
Let me get the scenario straight:
You await for a login, and when this step is done it shows a logo on a different page right?
If that's the case then I might guess the issue.
Lets say that the function login() is done, before it is able to render the logo in the DOM it already runs the app.Page.getLogo().
So you have a scenario like;
Login() then
renders logo then
getLogo()
So you have a complexity of finding the rendering time from page1 -> page 2. This is not a constant time. So what you want to is to have something which runs a code and check for a specif element multiple times, in the DOM.
I'm not sure how your test has been made to check if the logo is available or not in the page, but I would recommend you to look for a id tag in the DOM.
Just to see if it your await function works, make a timeout after you call
await page.login(); and see what happens, Set the timeout to 30 seconds just check.
So Usually when its about page rendering you would probably need a sleep timer which checks if the element on the next page is there (element of your logon-logo etc.)
A code reference would be;
wait for complete page load does not work as expected in Protractor
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444168%2fprotractor-test-hangs-on-await-browser-wait-with-disabled-control-flow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Let me get the scenario straight:
You await for a login, and when this step is done it shows a logo on a different page right?
If that's the case then I might guess the issue.
Lets say that the function login() is done, before it is able to render the logo in the DOM it already runs the app.Page.getLogo().
So you have a scenario like;
Login() then
renders logo then
getLogo()
So you have a complexity of finding the rendering time from page1 -> page 2. This is not a constant time. So what you want to is to have something which runs a code and check for a specif element multiple times, in the DOM.
I'm not sure how your test has been made to check if the logo is available or not in the page, but I would recommend you to look for a id tag in the DOM.
Just to see if it your await function works, make a timeout after you call
await page.login(); and see what happens, Set the timeout to 30 seconds just check.
So Usually when its about page rendering you would probably need a sleep timer which checks if the element on the next page is there (element of your logon-logo etc.)
A code reference would be;
wait for complete page load does not work as expected in Protractor
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
add a comment |
Let me get the scenario straight:
You await for a login, and when this step is done it shows a logo on a different page right?
If that's the case then I might guess the issue.
Lets say that the function login() is done, before it is able to render the logo in the DOM it already runs the app.Page.getLogo().
So you have a scenario like;
Login() then
renders logo then
getLogo()
So you have a complexity of finding the rendering time from page1 -> page 2. This is not a constant time. So what you want to is to have something which runs a code and check for a specif element multiple times, in the DOM.
I'm not sure how your test has been made to check if the logo is available or not in the page, but I would recommend you to look for a id tag in the DOM.
Just to see if it your await function works, make a timeout after you call
await page.login(); and see what happens, Set the timeout to 30 seconds just check.
So Usually when its about page rendering you would probably need a sleep timer which checks if the element on the next page is there (element of your logon-logo etc.)
A code reference would be;
wait for complete page load does not work as expected in Protractor
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
add a comment |
Let me get the scenario straight:
You await for a login, and when this step is done it shows a logo on a different page right?
If that's the case then I might guess the issue.
Lets say that the function login() is done, before it is able to render the logo in the DOM it already runs the app.Page.getLogo().
So you have a scenario like;
Login() then
renders logo then
getLogo()
So you have a complexity of finding the rendering time from page1 -> page 2. This is not a constant time. So what you want to is to have something which runs a code and check for a specif element multiple times, in the DOM.
I'm not sure how your test has been made to check if the logo is available or not in the page, but I would recommend you to look for a id tag in the DOM.
Just to see if it your await function works, make a timeout after you call
await page.login(); and see what happens, Set the timeout to 30 seconds just check.
So Usually when its about page rendering you would probably need a sleep timer which checks if the element on the next page is there (element of your logon-logo etc.)
A code reference would be;
wait for complete page load does not work as expected in Protractor
Let me get the scenario straight:
You await for a login, and when this step is done it shows a logo on a different page right?
If that's the case then I might guess the issue.
Lets say that the function login() is done, before it is able to render the logo in the DOM it already runs the app.Page.getLogo().
So you have a scenario like;
Login() then
renders logo then
getLogo()
So you have a complexity of finding the rendering time from page1 -> page 2. This is not a constant time. So what you want to is to have something which runs a code and check for a specif element multiple times, in the DOM.
I'm not sure how your test has been made to check if the logo is available or not in the page, but I would recommend you to look for a id tag in the DOM.
Just to see if it your await function works, make a timeout after you call
await page.login(); and see what happens, Set the timeout to 30 seconds just check.
So Usually when its about page rendering you would probably need a sleep timer which checks if the element on the next page is there (element of your logon-logo etc.)
A code reference would be;
wait for complete page load does not work as expected in Protractor
edited Nov 23 '18 at 12:42
answered Nov 23 '18 at 10:52
Zot3xZot3x
588
588
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
add a comment |
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
you're right, I tried adding timeout before waiting for element to be present. but in this case I have a question: how do I wait until new page is rendered after login? is there good way to check without setting a timeout?
– Blind Despair
Nov 23 '18 at 11:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444168%2fprotractor-test-hangs-on-await-browser-wait-with-disabled-control-flow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This this: var checkExist = setInterval(function() { browser.getCurrentUrl().then(function(currentURL){ if (currentURL == baseUrl+'/login') { clearInterval(checkExist); } }) }, 1000); // check every 1000ms w3schools.com/js/js_timing.asp
– Alexandre
Nov 23 '18 at 9:57