0

How to use wait for element to be clickable and wait for element to be present in protractor? I know this will help only with 1 element. Not for all.

For Example:-

Here is the website link, I am trying to automate using protractor and I do not want to use sleep in any case.

Steps to reproduce:-

  1. Navigate to https://www.celebritycruises.com.
  2. Click on Find A Cruise at top left corner and click on Find Cruise button.
  3. It will be navigated to this link - celebritycruises.com/spa/#/itinerary-search.
  4. Now here is the thing, This page takes time to load. So, I am trying to wait for the element or wait for element to be clickable. But it is getting failed.

    browser.get('https://www.celebritycruises.com');

    var pop = element(by.css('a.popover-find-cruise'));
    pop.click().then(function() {
    
    element.all(by.css('.cta.find-cruise-button button')).last().click();
    
    });
    
    var dta = element(by.css('.itinerary-search.spa #nav-departure-date'));
    
    var EC = protractor.ExpectedConditions;
    browser.wait(EC.visibilityOf(dta), 30000);
    
    dta.click();
    

Can you please help me on this?

  • Please post the error, "It is getting failed" is not useful information – Gunderson Jun 19 '17 at 12:16
  • Nevermind, that page isn't angular from what I can see so im assuming you are getting a synchronous timeout from angular. Please read https://github.com/angular/protractor/blob/master/docs/timeouts.md or other docs on how to use protractor with non-angular apps, such as http://ng-learn.org/2014/02/Protractor_Testing_With_Angular_And_Non_Angular_Sites/ – Gunderson Jun 19 '17 at 12:20
  • Did you read this article: https://stackoverflow.com/questions/21748442/protractor-how-to-wait-for-page-complete-after-click-a-button?rq=1 – Dao Minh Dam Jun 21 '17 at 07:04

0 Answers0