[英]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.