QAAuto :
Here, to locate checkbox, XPath is written as below. //td[text()='bbbb vvvvvvvvv']/preceding-sibling::td/div/input[@class='hidden']
But this input is not captured. util "//td[text()='bbbb vvvvvvvvv']/preceding-sibling::td/div/", element is located. Is there any perticulare reason for that?. I want to know why this XPath is not working?
KunduK :
Try webdriverwait and any of follwoing options.
Option1:
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='id' and @type='checkbox']")));
element.click();
Option2:
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='id' and @type='checkbox']")));
Actions action=new Actions(driver);
action.moveToElement(element).click().build().perform();
Option3:
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element1 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='id' and @type='checkbox']")));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",element1);