简体   繁体   English

如何使用Java使用Selenium WebDriver验证是否单击了按钮

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

I want to verify whether a button is clicked or not with Selenium WebDriver using Java. 我想使用Java使用Selenium WebDriver验证是否单击了按钮。 How can I verify this? 我该如何验证?

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");

The only way to know if a button is clicked.. Is to actually validate the response you get when you click the button. 知道是否单击了按钮的唯一方法是真正验证单击按钮时得到的响应。 And why would you want to know if it is clicked.. You want to validate the response.. As long as you can find that element, then you can click it.. If you cant find or click it, then an exception will occur.. Once you click.. you validate the response. 以及为什么要知道是否单击了它。您想验证响应。只要找到该元素,您就可以单击它。如果找不到或单击它,则会发生异常..一旦单击..您验证响应。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Selenium Webdriver中使用Java验证HTML代码中是否存在用于下拉列表的标记 - How to verify whether a tag is present in the html code for a drop down using java in Selenium Webdriver 如何使用Java验证Selenium WebDriver中的tooltipText - How to verify tooltipText in Selenium WebDriver using Java 如何验证硒webdriver中是否存在浏览器 - How to verify whether a browser exists in selenium webdriver 等待直到使用Java在Selenium Webdriver中手动单击登录按钮 - Wait until login button is manually clicked in selenium webdriver using Java 如何在使用带有 Java 的 Selenium WebDriver 单击网页上的上传按钮时显示的 Windows 资源管理器上单击取消 - How to click on Cancel on a windows explorer that displays when a upload button is clicked on a web page using Selenium WebDriver with Java 如何在网页上使用带有 Java 的 Selenium WebDriver 验证工具提示文本 - How to verify tooltip text using Selenium WebDriver with java on a webpage 如果对象在Selenium Webdriver Java中不可见,如何使用xpath验证对象 - how to verify object using xpath if object is invisible in selenium webdriver java 如何使用Java在Selenium Webdriver中验证单词是否为粗体? - How to verify that a word is Bold in selenium webdriver using Java? 使用Java在Selenium WebDriver中发布后,每次如何验证文本? - How to verify text everytime after posting with Selenium WebDriver using java? 如何使用Java使用Selenium WebDriver验证动态库? - How to verify dynamic gallery with Selenium WebDriver using Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM