dimanche 12 juillet 2020

How to select a single check box among multiple boxes based on the label text

Hi I am trying to automate a scenario where a search is initiated using City name and that would give me the list of available test centers in the city with check boxes to choose required test center. I have tried many ways but failed to locate the Test center based on the 'Post code' available in label text of specific center. Please click here for the code

I could locate individual test centers using the xpath and id of respective test center as shown below, but couldn't come up with a common locator to identify one test center among multiple centers.

WebDriverWait wait = new WebDriverWait(driver, 10000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*@id='selectedTestCenters:4']")));
driver.findElement(By.xpath("//*[@id='selectedTestCenters:4']")).click();

To locate the test center based on text I have used below line but it didn't work.

driver.findElement(By.xpath("//*[@id='testCenterListTable']/tr[5]/td/label[contains(text(),'SG1 2EF')]")).click();

Suggestions please?

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire