2016-01-06 32 views
-1

xpath = //strong[text()='Review the information below, then click "Cancel this Order."']如何斷言是否有2個webelements?

描述:

  1. 利用上述的xpath 2個元件得到使用firepath位於在Firefox。
  2. 我想斷言頁面中是否有2個可用元素。
  3. 嘗試用下面的代碼,但它返回0; @Locator(as=As.XPATH,use ="//strong[text()='Review the information below, then click "Cancel this Order.")

代碼:

public List<PageElement> reviewTextElement; 

public int count(){ 
    int count= reviewTextElement.size(); 
    return count; 
} 
+0

它看起來像在xpath中缺少關閉']'提供HTML代碼來幫助您使用xpath –

回答

0

代碼是因爲的xpath的返回0不識別的元素。使用轉義序列\"圍繞Cancel this Order應該解決問題,如果您提到的xpath是正確的。

@Locator(as=As.XPATH, use ="//strong[text()='Review the information below, then click \"Cancel this Order.\"")