简体   繁体   English

如何使用Selenium WebDriver和Java根据HTML单击复选框

[英]How to click on the checkbox as per the HTML using Selenium WebDriver and Java

尝试使用以下代码检查复选框

<label class="checkboxPlainLabel" for="Quote_SensitiveDataConfirmation">

You can click it like below code : 您可以按以下代码单击它:

driver.findElement(By.xpath("//label[@for='Quote_SensitiveDataConfirmation']")).click();

Hope that helps you:) 希望对您有帮助:)

As per the HTML you have provided to click on the checkbox you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions: 根据您提供的用于单击复选框HTML ,需要诱导WebDriverWait使元素可单击,并且可以使用以下任一解决方案:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//label[@for='Quote_SensitiveDataConfirmation']"))).click();
//or
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='Quote_SensitiveDataConfirmation']"))).click();

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

相关问题 Selenium Webdriver Java:单击复选框 - Selenium Webdriver java: click on a checkbox Selenium Webdriver-Java-如何根据产品单击复选框 - Selenium Webdriver - Java - How to click checkbox based on product 如何使用Java修复Selenium Webdriver中的复选框? - How can i fix my checkbox click in Selenium Webdriver with Java? 如何使用PhantomJS和Selenium单击Java中的复选框? - How to click a checkbox in Java using PhantomJS and Selenium? 如何使用Java使用Selenium Webdriver单击此注销图标 - How to click this Logout Icon using Selenium Webdriver using Java 即使显示复选框,单击复选框也无法使用 Selenium webdriver 工作 - Click checkbox not working using Selenium webdriver even if checkbox is displayed 如何通过Selenium和Java按照HTML的方式单击文本为Continue的元素 - How to click on the element with text as Continue as per the HTML through Selenium and Java 如何根据通过 Selenium 和 Java 提供的 HTML 单击 img 标签? - How to click on img tag as per the HTML provided through Selenium and Java? 如何通过Selenium和Java按html上的单击取消按钮 - How to click on the Cancel button as per the html through Selenium and Java 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击允许按钮 - How to click on allow button on popup window in selenium Webdriver by using Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM