To get the value of id
attribute induce WebDriverWait
() and visibilityOfElementLocated
() and following xpath options.
XPATH 1:
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[contains(., 'Bilable to Client')]/preceding::input[1]"))).getAttribute("id");
OR
XPATH 2:
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[contains(., 'Bilable to Client')]/preceding-sibling::td[1]/input"))).getAttribute("id");
OR
XPATH 3:
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//table[@id='level3InnerTable_1']//tr[@id='Billable Client'][.//td[.//input]]]//input"))).getAttribute("id");
Note: If you get timeout exception from all them then check if there any iframe on the page.