Preceding sibling is not working if there are multiple child tags

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?

enter image description here

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=158812&siteId=1