簡體   English   中英

如何使用Java使用Selenium WebDriver驗證是否單擊了按鈕

[英]How to verify whether a Button is clicked or not with Selenium WebDriver using Java

我想使用Java使用Selenium WebDriver驗證是否單擊了按鈕。 我該如何驗證?

public static boolean isClickable(WebElement webe){
try
{ 
WebDriverWait wait = new WebDriverWait(yourWebDriver, 5);
wait.until(ExpectedConditions.elementToBeClickable(webe));
   return true;
 }
catch (Exception e)
{
return false;
 }

boolean bst = className.isClickable("your element");

知道是否單擊了按鈕的唯一方法是真正驗證單擊按鈕時得到的響應。 以及為什么要知道是否單擊了它。您想驗證響應。只要找到該元素,您就可以單擊它。如果找不到或單擊它,則會發生異常..一旦單擊..您驗證響應。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM