protractor hangs after running a .sendKeys



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am new to using protractor and am struggling with getting even a simple script running.



The symptom is "field1" is populated and then the script hangs. Removing the "await" on the .sendKeys causes the script to run but if I then move "if (await field2.isPresent()) {" down to below the "field1" sendKeys then once again only the "field1" is populated.



The issue seems to me to be around promises, but only a guess. What I need is to be able to have my .isPresent checks anywhere in my scripts. This is obviously a simplified example and is done for ease of explanation.



angular version 6



protractor.conf.js



allScriptsTimeout: 30000,
...
SELENIUM_PROMISE_MANAGER: false,



package.json extract



"cucumber": "^5.0.2",
"cucumber-html-reporter": "^4.0.4",
"jasmine": "^3.3.0",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"protractor": "^5.4.1",
"protractor-cucumber-framework": "^6.1.1",
"protractor-html-screenshot-reporter": "0.0.21",



Given ('peek capture is running', timeout: 30000, async function () 
await browser.get('#/login');
let field1: ElementFinder = element(by.id('login-email'));
let field2: ElementFinder = element(by.id('login-password'));
let field3: ElementFinder = element(by.css('#theButton'));
if (await field1.isPresent())
if (await field2.isPresent())
await field1.sendKeys('theuser@the.org');
await field2.sendKeys('the password');
await field3.click();

await browser.sleep(1500);


return(null);
);









share|improve this question






















  • First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

    – Sergey Pleshakov
    Nov 16 '18 at 14:06

















1















I am new to using protractor and am struggling with getting even a simple script running.



The symptom is "field1" is populated and then the script hangs. Removing the "await" on the .sendKeys causes the script to run but if I then move "if (await field2.isPresent()) {" down to below the "field1" sendKeys then once again only the "field1" is populated.



The issue seems to me to be around promises, but only a guess. What I need is to be able to have my .isPresent checks anywhere in my scripts. This is obviously a simplified example and is done for ease of explanation.



angular version 6



protractor.conf.js



allScriptsTimeout: 30000,
...
SELENIUM_PROMISE_MANAGER: false,



package.json extract



"cucumber": "^5.0.2",
"cucumber-html-reporter": "^4.0.4",
"jasmine": "^3.3.0",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"protractor": "^5.4.1",
"protractor-cucumber-framework": "^6.1.1",
"protractor-html-screenshot-reporter": "0.0.21",



Given ('peek capture is running', timeout: 30000, async function () 
await browser.get('#/login');
let field1: ElementFinder = element(by.id('login-email'));
let field2: ElementFinder = element(by.id('login-password'));
let field3: ElementFinder = element(by.css('#theButton'));
if (await field1.isPresent())
if (await field2.isPresent())
await field1.sendKeys('theuser@the.org');
await field2.sendKeys('the password');
await field3.click();

await browser.sleep(1500);


return(null);
);









share|improve this question






















  • First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

    – Sergey Pleshakov
    Nov 16 '18 at 14:06













1












1








1








I am new to using protractor and am struggling with getting even a simple script running.



The symptom is "field1" is populated and then the script hangs. Removing the "await" on the .sendKeys causes the script to run but if I then move "if (await field2.isPresent()) {" down to below the "field1" sendKeys then once again only the "field1" is populated.



The issue seems to me to be around promises, but only a guess. What I need is to be able to have my .isPresent checks anywhere in my scripts. This is obviously a simplified example and is done for ease of explanation.



angular version 6



protractor.conf.js



allScriptsTimeout: 30000,
...
SELENIUM_PROMISE_MANAGER: false,



package.json extract



"cucumber": "^5.0.2",
"cucumber-html-reporter": "^4.0.4",
"jasmine": "^3.3.0",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"protractor": "^5.4.1",
"protractor-cucumber-framework": "^6.1.1",
"protractor-html-screenshot-reporter": "0.0.21",



Given ('peek capture is running', timeout: 30000, async function () 
await browser.get('#/login');
let field1: ElementFinder = element(by.id('login-email'));
let field2: ElementFinder = element(by.id('login-password'));
let field3: ElementFinder = element(by.css('#theButton'));
if (await field1.isPresent())
if (await field2.isPresent())
await field1.sendKeys('theuser@the.org');
await field2.sendKeys('the password');
await field3.click();

await browser.sleep(1500);


return(null);
);









share|improve this question














I am new to using protractor and am struggling with getting even a simple script running.



The symptom is "field1" is populated and then the script hangs. Removing the "await" on the .sendKeys causes the script to run but if I then move "if (await field2.isPresent()) {" down to below the "field1" sendKeys then once again only the "field1" is populated.



The issue seems to me to be around promises, but only a guess. What I need is to be able to have my .isPresent checks anywhere in my scripts. This is obviously a simplified example and is done for ease of explanation.



angular version 6



protractor.conf.js



allScriptsTimeout: 30000,
...
SELENIUM_PROMISE_MANAGER: false,



package.json extract



"cucumber": "^5.0.2",
"cucumber-html-reporter": "^4.0.4",
"jasmine": "^3.3.0",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "4.2.1",
"protractor": "^5.4.1",
"protractor-cucumber-framework": "^6.1.1",
"protractor-html-screenshot-reporter": "0.0.21",



Given ('peek capture is running', timeout: 30000, async function () 
await browser.get('#/login');
let field1: ElementFinder = element(by.id('login-email'));
let field2: ElementFinder = element(by.id('login-password'));
let field3: ElementFinder = element(by.css('#theButton'));
if (await field1.isPresent())
if (await field2.isPresent())
await field1.sendKeys('theuser@the.org');
await field2.sendKeys('the password');
await field3.click();

await browser.sleep(1500);


return(null);
);






async-await protractor sendkeys






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 10:40









David HaywardDavid Hayward

61




61












  • First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

    – Sergey Pleshakov
    Nov 16 '18 at 14:06

















  • First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

    – Sergey Pleshakov
    Nov 16 '18 at 14:06
















First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

– Sergey Pleshakov
Nov 16 '18 at 14:06





First of all, do you use if (.isPresent()) twice to make sure that the page is loaded? And second, somehow protractor doesn't work on my login page as it was non angular (even though it is angular indeed). So I had to await browser.waitForAngularEnabled(false); before openning the page and await browser.waitForAngularEnabled(true); after I logged in. But I was getting errors specific to this problem. So try second option, if doesn't help, answer first question and we'll go from there

– Sergey Pleshakov
Nov 16 '18 at 14:06












1 Answer
1






active

oldest

votes


















0














You can make use of ExpectedConditions in protractor



https://www.protractortest.org/#/api?view=ProtractorExpectedConditions



Given ('peek capture is running', timeout: 30000, async function () 

var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();

)





share|improve this answer























  • If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

    – David Hayward
    Nov 20 '18 at 12:16











  • Did you add await keyword before browser.wait?

    – Bharath Kumar S
    Nov 20 '18 at 12:33











  • Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

    – David Hayward
    Nov 21 '18 at 16:31











  • You should resolve or reject the promise.

    – Bharath Kumar S
    Nov 21 '18 at 16:45











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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336177%2fprotractor-hangs-after-running-a-sendkeys%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









0














You can make use of ExpectedConditions in protractor



https://www.protractortest.org/#/api?view=ProtractorExpectedConditions



Given ('peek capture is running', timeout: 30000, async function () 

var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();

)





share|improve this answer























  • If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

    – David Hayward
    Nov 20 '18 at 12:16











  • Did you add await keyword before browser.wait?

    – Bharath Kumar S
    Nov 20 '18 at 12:33











  • Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

    – David Hayward
    Nov 21 '18 at 16:31











  • You should resolve or reject the promise.

    – Bharath Kumar S
    Nov 21 '18 at 16:45















0














You can make use of ExpectedConditions in protractor



https://www.protractortest.org/#/api?view=ProtractorExpectedConditions



Given ('peek capture is running', timeout: 30000, async function () 

var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();

)





share|improve this answer























  • If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

    – David Hayward
    Nov 20 '18 at 12:16











  • Did you add await keyword before browser.wait?

    – Bharath Kumar S
    Nov 20 '18 at 12:33











  • Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

    – David Hayward
    Nov 21 '18 at 16:31











  • You should resolve or reject the promise.

    – Bharath Kumar S
    Nov 21 '18 at 16:45













0












0








0







You can make use of ExpectedConditions in protractor



https://www.protractortest.org/#/api?view=ProtractorExpectedConditions



Given ('peek capture is running', timeout: 30000, async function () 

var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();

)





share|improve this answer













You can make use of ExpectedConditions in protractor



https://www.protractortest.org/#/api?view=ProtractorExpectedConditions



Given ('peek capture is running', timeout: 30000, async function () 

var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();

)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 14:10









Bharath Kumar SBharath Kumar S

5791421




5791421












  • If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

    – David Hayward
    Nov 20 '18 at 12:16











  • Did you add await keyword before browser.wait?

    – Bharath Kumar S
    Nov 20 '18 at 12:33











  • Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

    – David Hayward
    Nov 21 '18 at 16:31











  • You should resolve or reject the promise.

    – Bharath Kumar S
    Nov 21 '18 at 16:45

















  • If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

    – David Hayward
    Nov 20 '18 at 12:16











  • Did you add await keyword before browser.wait?

    – Bharath Kumar S
    Nov 20 '18 at 12:33











  • Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

    – David Hayward
    Nov 21 '18 at 16:31











  • You should resolve or reject the promise.

    – Bharath Kumar S
    Nov 21 '18 at 16:45
















If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

– David Hayward
Nov 20 '18 at 12:16





If I use "browser.wait(EC.visibilityOf(field),10000);" then the code does not stop, however looking at browser.wait I see it is returning a promise so I need an "await" on the browser.wait. If I do the problem returns and the script times out, if I do not use a await on the browser.wait then the script just runs straight through the line with no wait for the element.

– David Hayward
Nov 20 '18 at 12:16













Did you add await keyword before browser.wait?

– Bharath Kumar S
Nov 20 '18 at 12:33





Did you add await keyword before browser.wait?

– Bharath Kumar S
Nov 20 '18 at 12:33













Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

– David Hayward
Nov 21 '18 at 16:31





Yes, if I did not then browser.wait does not wait. As I understand it if I set SELENIUM_PROMISE_MANAGER: false, then I handle promises, and as I am using new promises I used await. Am I wrong?

– David Hayward
Nov 21 '18 at 16:31













You should resolve or reject the promise.

– Bharath Kumar S
Nov 21 '18 at 16:45





You should resolve or reject the promise.

– Bharath Kumar S
Nov 21 '18 at 16:45



















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336177%2fprotractor-hangs-after-running-a-sendkeys%23new-answer', 'question_page');

);

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







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線