xpath select td class contains text

Solutions on MaxInterview for xpath select td class contains text by the best coders in the world

showing results for - "xpath select td class contains text"
Taina
18 Jul 2016
1xpath=//td[@title='Main']/following-sibling::td[contains(text(), 'Show')]
Nik
25 Nov 2019
1// Get the content or container    
2WebElement content = driver.findElement(By.id("contentText"));
3
4//Get the table of users
5WebElement tblUsers = content.findElement(By.xpath(".//table/tbody/tr[2]/td/table/tbody/tr/td[1]/table"));
6
7// Get the rows which change always as and when users are added
8WebElement allUsers = tblUsers.findElements(By.xpath(".//tbody/tr"));
9
10// Loop through each row of users table
11for(WebElement user : allUsers) {
12
13   // Get the username
14   WebElement username = user.findElement(By.xpath(".//td/table/tbody/tr/td[1]/strong[2]"));
15   System.out.println("Username: " + username.getText());
16}
17