【问题标题】:Wait for text change in td with protractor使用量角器等待 td 中的文本更改
【发布时间】:2017-11-12 07:14:04
【问题描述】:

我有带有sortable columns 的表,当单击排序列时,我需要等待排序完成,以检测表中的数据更改我试图将td 中的当前文本保存在变量中,然后在@987654323 中进行比较@ 到第一个 td 的新文本

waitForTDValueChange(currentValue: string, index: number): void {
     browser.wait(
         () => element.all(by.css('td[data-header="HEADERNAME"]'))
         .get(index)
         .getText()
         .then((txt) => {
             return txt !== currentValue;
         }), 30000);
}

这是我的代码,但它会抛出 Stale Element Reference Exception.. 有什么想法吗?

【问题讨论】:

    标签: angular selenium typescript protractor e2e-testing


    【解决方案1】:

    也许您可以将locator cssContainingText()Expected Condition stalenessOfcheck for indexOf !== 0 一起使用。

    类似这样的:

    var EC = protractor.ExpectedConditions; 
    //or "global.EC = protractor.ExpectedConditions;" in conf.js to have it globally available
    waitForTDValueChange = function(currentValue, index){
        var list = element.all(by.css('td[data-header="HEADERNAME"]'));
        var el = element(by.cssContainingText('td[data-header="HEADERNAME"]', currentValue))
        //idea 1 - not sure, if it only works, when el disappears, so position change might not be sufficient
        browser.wait(EC.stalenessOf(el), 5000);
        //idea 2 - get index of current element until it's not on index = 0 anymore
        browser.wait(list.indexOf(el) !== 0, 5000);
    };
    

    【讨论】:

      猜你喜欢
      • 2016-03-25
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多