[英]Protractor waits during ignore synchronization, browser implicitTimeout vs browser.wait timeout
我有一個應用程序在單擊按鈕時啟動$ timeout,因此我必須將ignoreSynchronization設置為true。 在此期間,我需要等待將元素添加到頁面中,並且在等待期間我遇到了一些有趣的行為:
在browser.wait(元素,超時,錯誤消息)期間傳入的等待超時不執行任何操作。 唯一重要的等待是在瀏覽器上設置的implicitTimeout。 最重要的是,將使用ENTIRE隱式超時。 如果發現該元素存在,它將繼續檢查直到超時結束。 這意味着測試將始終緩慢運行,並給出最大時間。
describe('Cool Page', () =>{
beforeEach(function(){
browser.ignoreSynchronization = true;
return browser.sleep(250);
});
afterEach(function(){
browser.ignoreSynchronization = false;
return browser.sleep(250);
});
it('can open menu with timeout', function(){
// No timeout at this point
coolPage.wait.ellipsesIcons().then(() =>{
// Clicking the ellipses icons kicks off a $timeout of 100 seconds
coolPage.ellipsesIcons.click().then(() =>{
coolPage.wait.dropdownOptions().then(() => {
expect(coolPage.dropdownOptions.getText()).toContain('Option 1');
});
});
});
});
})
。
export = new CoolPage;
class CoolPageextends PageObject {
private elements;
constructor(){
super();
... // Lots of other stuff
this.initWait();
}
... // Initializing elements and other things
private initWait() {
this.wait = {
ellipsesIcons: () => {
// Timeout of 5 seconds will be used - regardless of isPresent resolving as true or false, the entire 5 seconds will be used
browser.manage().timeouts().implicitlyWait(5000);
// The 2 milliseconds passed in here does nothing at all
browser.wait(element(by.css('.fa-ellipses-h')).isPresent(), 2, 'Ellipses Icon(...) was not present in time');
// Must reset implicit wait back to the original 25 seconds it was set too in the conf
browser.manage().timeouts().implicitlyWait(25000);
return browser.sleep(150);
},
dropdownOptions: () => {
// This two seconds wait WILL be used
browser.manage().timeouts().implicitlyWait(2000);
// This five second wait WILL NOT be used
browser.wait(element(by.css('[name="change-status"]')).isPresent(), 5000, 'Options actions menu item was not present in time');
browser.manage().timeouts().implicitlyWait(25000);
return browser.sleep(150);
},
}
}
通過browser.wait傳遞的超時對此沒有影響。 我的問題是:
嘗試使用瀏覽器等待的預期條件 。 使用函數textToBePresentInElement
查看it('should wait for a series of periodic increments'
作為示例。要檢查元素是否存在,我可能會嘗試visibilityOf
或presenceOf
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.