2017-11-17 7 views
0

저는 끝 테스트를 위해 각도기에서 작업 중이며 버튼을 클릭하기 전에 상태 표시기가 사라지는 지 확인해야합니다. 지금은 할 수 없습니다. invisibilityOf()stalenessOf()을 사용하려고했지만 작동하지 않습니다.각도기의 상태 표시기를 확인할 수 없습니다.

여기 PageObject에 내 코드입니다 :

public isNotPresent(elem) { 
    return browser.wait(protractor.ExpectedConditions.stalenessOf(elem), 5000).then(function() { 
     console.log("Status indicator is not present in DOM"); 
     return true; //success 
    },function() { 
     console.log("Status indicator is present in DOM"); 
     return false; //Failure 
    }); 
} 

public waitForStatusIndicator(){ 
    console.log('in method wait for status indicator'); 
    return this.isNotPresent(element(by.css('#api-status-indicator'))).then((isNotPresent)=>{ 
     return isNotPresent; 
    }); 
} 

은 다음과 같습니다 그것은 '< # API를-상태 표시기>, 다른 요소는 클릭을받을 시점 (540823)에서 클릭 할 수 없습니다'오류가 표시됩니다 어디서 상태 표시기를 확인하려고하는지 :

PageObject.waitForStatusIndicator().then(function (isNotPresent) { 
     if(isNotPresent == true) { 
     someButton.click(); 
     return expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + "/login"); 
     } 
}) 

어디로 가고 있습니까?

+0

노드를 완전히 삭제하면 더 이상 발견 할 수없는 것이 정상입니다. 'stalenessOf'를 사용하기 전에 이것이 처음 존재하는지 확인하십시오. –

답변

1

요소가 DOM에 처음 나타나고 DOM에없는 경우 먼저 요소가 보이지 않을 때까지 기다렸다가 다시 확인해야합니다. 이 같은

전반적으로 뭔가 :

public isNoLongerPresent(elem) { 
    //NOTE: If any of the expected conditions don't happen, your code times out. 
    //No need for false-check or similar 
    var EC = protractor.ExpectedConditions; 
    browser.wait(EC.presenceOf(elem), 5000); 
    browser.wait(EC.visibilityOf(elem), 5000); //Note, that visibilityOf requires presence 
    return browser.wait(EC.stalenessOf(elem), 5000); 
} 

public waitForStatusIndicator(){ 
    console.log('in method wait for status indicator'); 
    return this.isNoLongerPresent(element(by.css('#api-status-indicator'))); 
} 

그리고 당신의 사양 : 어떤 then() 필요 다시 없다. 각도기가 동기식으로 실행하고 도중에 false이있는 경우 코드가 시간 초과됩니다.

PageObject.waitForStatusIndicator(); 
someButton.click(); 
return expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + "/login");