I am having trouble getting some checkboxes to be clicked. the usual XPath does not work, and there is no ID. I have attached the HTML code.
driver.findElement(By.className("custom-control-label")).click();
Try above line. Thanks.
To click()
on the element you can use either of the following Locator Strategies :
cssSelector
:
driver.findElement(By.cssSelector("input#contactAuth")).click();
xpath
:
driver.findElement(By.xpath("//input[@id='contactAuth']")).click();
Ideally, to click()
on the element, you need to induce WebDriverWait for the elementToBeClickable()
and you can use either of the following Locator Strategies :
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.birtviewer_clickable[name='exportReport']"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='birtviewer_clickable']"))).click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.