Protractor waiting for element to be in DOM

前端 未结 3 1220
生来不讨喜
生来不讨喜 2020-12-05 03:50

I have been having some trouble using Protractor. I have a really weird ui-router state where its hard to go off of other elements to start working with the page. Is there a

相关标签:
3条回答
  • 2020-12-05 04:31

    Protractor has included ExpectedCondition for explicit wait which lets you wait for the element for certain period of time. You should be able to do the following:

    var EC = protractor.ExpectedConditions;
    
    browser.driver.wait(function () {
        browser.wait(EC.visibilityOf(elem), 10000);
        return elem;
    });
    
    0 讨论(0)
  • 2020-12-05 04:46

    the first parameter of browser.wait is a function, if we need to wait until an element is present irrespective of time, then we can use the below code, If you need to restrict the wait to a particular time please give time as second parameter of 'browser.wait'

    browser.wait(function() {
        return element(by.css("#edudrop1")).isPresent()});
    
    0 讨论(0)
  • 2020-12-05 04:50

    You should be able to use browser.wait together with the presenceOf ExpectedCondition:

    var until = protractor.ExpectedConditions;
    browser.wait(until.presenceOf(elem), 5000, 'Element taking too long to appear in the DOM');
    
    0 讨论(0)
提交回复
热议问题