2016-01-06 33 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.\"")