2017-10-29 46 views
0

我正在創建量角器腳本,並且需要驗證屏幕上是否顯示錯誤消息,但消息僅設置爲顯示3秒。量角器:需要幫助來查找只顯示3秒的錯誤消息

如屏幕截圖screenshot of alert - error message(僅顯示3秒鐘)所示,我應該能夠通過span標籤找到消息,但它不起作用。

在我的打字代碼中,我嘗試了以下內容。 CSS代碼:

private errorMsgRetrieveCards = element(by.css('alerts-component>div:nth-of-type(1)>div>span:nth-of-type(1)')); 

及以下.xpath代碼:

private errorMsgRetrieveCards = element(by.xpath('/html/body/consumer-component/div/consumer-details-component/div/alerts-component/div/')); 

在這兩種情況下,我收到相同的錯誤消息,當我在量角器運行我的腳本:

Failed: No element found using locator: By(css selector, alerts-component>div:nth-of-type(1)>div>span:nth-of-type(1)) 

棧: NoSuchElementError:找不到使用locator的元素:By(css selector,alerts-component> div:nth-​​of-type(1)> div> span:n-type(1)) at WebDriverError(/ wo rk/paysafe-wab-web-admin-fe/frontend/node_modules/selenium-webdriver/lib/error.js:27:5)

有什麼建議嗎?

回答

0

運行此事先一般能解決問題,我

browser.wait(EC.presenceOf(element(by.xpath(/html/body/consumer-component/div/consumer-details-component/div/alerts-component/div/'))))