0

I have a test case where I create certain objects through REST APIs. The creation of that object takes about 4-5 mins. I want the test to wait till the creation is complete and validate that the object was created. Is there a way to achieve this long wait with protractor? (I have tried many things but nothing seems to be getting me closer to what I'm trying to achieve)

The reason why I need to validate (apart from making sure it works) is that after that I need to test deletion of that object and don't have a way to make the tests wait till the creation was complete.

Code for test

it('should create object', function (done) {
    //create objects (click on submit buttons basically this part works fine)
    var addButton = homePage.addButton;
    for (var i = 0; i < 2 ; i++){
        addButton.get(i).click();
    }

    // in my page after I click creation it shows a loader for each item and
    // till it completes. When it completes it shows the item itself without 
    // the progress bar 
    var pendingObject = element.all(by.id('.throbber-loader')).then(function (items) {
        return items;
    });

    while (pendingObject) {
        pendingObject = element.all(by.id('.throbber-loader')).then(function (items) {
            return items;
        });
        browser.wait(constants.SLEEP.MS2K);
    }
    // the pending objects are completed so I should be getting 0 of them 
    // and 2 created
    expect(pendingObject.count()).toEqual(0);

    var finishedObj = homePage.getItems;
    finishedObj.then(function(items){
        expect(pendingObject.count()).toEqual(2);
    })
    done();
});

Appreciate any pointers.

user2997962
  • 55
  • 1
  • 1
  • 6
  • Could you show the current code of your test? Is it failing, if yes - how? Thanks. – alecxe Nov 13 '15 at 22:11
  • Possible duplicate of [How can I wait for a condition?](http://stackoverflow.com/questions/22072327/how-can-i-wait-for-a-condition) – Yosef Weiner Nov 18 '15 at 21:12

0 Answers0