How to say protractor wait for page to load?

My application accepts some pages of the login page. So the protractor tries to enter the username before loading the page. So I need to say that the protractor is waiting for the login page to load.

Could you help me which command do I need to use for this and where do I need to use? (Please modify my code to add a wait command)

PFB for my onPrepare and beforeeach function

onPrepare: function() {  
browser.driver.manage().window().maximize();
jasmine.getEnv().addReporter(new HtmlReporter({

})
}

beforeEach(function() {
       browser.get('https://accounts.google.com/');
       //browser.manage().timeouts().pageLoadTimeout(30000);
       //browser.manage().timeouts().implicitlyWait(5000);
        //browser.sleep( 10000 );
        //browser.waitForAngular();
  });

I used these comments, but it did not work for me.

Please notify me in advance. Thanks in advance.

+4
source share
2 answers

wait: browser.driver.wait(, );

onPrepare: function() {  
    browser.driver.manage().window().maximize();
    jasmine.getEnv().addReporter(new HtmlReporter({
    });
}

beforeEach(function() {
       browser.driver.get('https://accounts.google.com/');
       return browser.driver.wait(function() {
            return browser.driver.getCurrentUrl().then(function (url) {
                return url.indexOf('https://accounts.google.com/') > -1;
            });
        }, 5000);
        //whatever you want after
  });

. , google f.e angular, : browser.driver.get browser.get, angular .

+3

, Get Started, wait, clickable:

var EC = protractor.ExpectedConditions;

var getStarted = element(by.css('button[title="Get started"]'));
browser.wait(EC.elementToBeClickable(getStarted), 5000);
getStarted.click();
+2

Source: https://habr.com/ru/post/1607663/


All Articles