如何找到可见的锚元素并在硒中单击它

时间:2017-05-04 17:45:49

标签: java selenium

我正在尝试找到一个显示单击的锚点。计算所有元素并使用isDisplayed()不是最佳的。有更快,更有效的方法吗?

1 个答案:

答案 0 :(得分:0)

假设你的主要元素是:

public boolean isPresent(WebElement element){

 try{
      elem ;

      return true;
    }
catch(Exception e){

      return false;

    }
}

或者,要验证是否显示此元素,您可以使用自定义方法:

SELECT     
    dbo.RtlStore.Description, 
    COUNT(dbo.InvProduct.U_OwnershipType) AS CONSIGNMENT, 
    COUNT(dbo.InvProduct.U_OwnershipType) AS OUTRIGHT, 
    COUNT(dbo.InvProduct.U_OwnershipType) AS HOURSEBRAND, 
    COUNT(dbo.InvProduct.U_OwnershipType) AS GOI, 
    COUNT(dbo.InvProduct.U_OwnershipType) AS OTHERS
FROM
    dbo.RtlStore 
LEFT OUTER JOIN
    dbo.InvProduct 
LEFT OUTER JOIN
    dbo.TrxTransactionSaleItem ON dbo.InvProduct.ProductKey = dbo.TrxTransactionSaleItem.ProductKey 
LEFT OUTER JOIN
    dbo.TrxTransaction ON dbo.TrxTransactionSaleItem.TransactionKey = dbo.TrxTransaction.TransactionKey 
    ON dbo.RtlStore.StoreKey = dbo.TrxTransaction.StoreKey
GROUP BY 
    dbo.RtlStore.Description
HAVING     
    (COUNT(dbo.InvProduct.U_OwnershipType) = N'CONSIGNMENT')
    AND (COUNT(dbo.InvProduct.U_OwnershipType) = N'OUTRIGHT')  
    AND (COUNT(dbo.InvProduct.U_OwnershipType) = N'HOUSEBRAND') 
    AND (COUNT(dbo.InvProduct.U_OwnershipType) = N'GOI')
    AND (COUNT(dbo.InvProduct.U_OwnershipType) = N'OTHERS')