2017-02-22 53 views
1

我正在使用protactor 5.1.1和chromedriver_2.27。 點擊時間表按鈕時,我想等待「調度完成」消息出現。我已經嘗試了下面的代碼(以及被評論的代碼),但沒有成功。量角器每次都會繼續。有任何想法嗎?量角器:尋找一個文本顯示當我點擊一個對象

enter image description hereenter image description here

that.serviceFilter.sendKeys(serviceName).then(function() { 
     utilsObj.doActionWithWait(that.serviceRowInServiceList, function() { 
      utilsObj.doActionWithWait(that.pickFilteredService, function() { 
       that.pickFilteredService.click().then(function() { 
        that.selectAllBtn.click().then(function() { 
         that.actionBtn.click().then(function() { 
          that.scheduleBtn.click() 



          // //EC = protractor.ExpectedConditions; 
          // var aaa = element(by.xpath("//*[@id='SchedulingInProgress']")); 
          // browser.wait(function() { 
          //  return EC.visibilityOf(aaa).call().then(function (present) { 
          //   console.log('\n' + 'looking for element....') 
          //   if (present) { 
          //    console.log('\n' + 'element not found!') 
          //    return true; 
          //   } 
          //   else { 
          //    console.log('\n' + 'element found!!') 
          //    return false; 
          //   } 
          //  }); 
          // }, 50000); 

         }); 
         browser.wait(function() { 
          return browser.driver.isElementPresent(by.xpath("//*[@id='SchedulingInProgress']")) 

         }) 


        }); 

       }); 

      }); 

     }); 

    }); 

回答

1

隨着錯誤消息表明您正在使用 - isElementPresent()不正確。它在ElementFinder對象上的功能而不是在驅動程序上。

不正確使用 - browser.driver.isElementPresent()

正確使用 - browser.driver.FindElement().isElementPresent()

更多細節here。如果你的目標是等待一個特定的元素出現..你正走在正確的道路上 - 使用Expected Conditions,它們很適合browser.wait。關於它的用法

0

browser.wait(EC.visibilityOf(element), 5000); //wait for an element to become點擊

here最後,我已經得到了解決 - 你可以做這樣的事!

var EC = protractor.ExpectedConditions; var elm = element(by.css("#SchedulingInProgress > div:nth-child(2) > div")); browser.wait(EC.visibilityOf(elm), 50000); expect(elm.getText()).toEqual('Scheduled 1 out of 1');

相關問題