System.out.println("The U value: " + u);
Statement stmt3 = null;
ResultSet srs3 = null;
List28 = new ArrayList<String>();
stmt3 = conn.createStatement();
String query = "SELECT [USERS_SYS_ID],[GROUPS_SYS_ID] as groupID FROM [USERS_GROUPS] WHERE [USERS_SYS_ID] = " + (u + 1);
srs3 = stmt3.executeQuery(query);
while (srs3.next()) {
List28.add(srs3.getString("groupID"));
}
System.out.println("Group ID: " + List28);
String z = "0";
z = null;
z = ("T_GROUP_" + List28.get(0));
driver.findElement(By.xpath(".//*[@id=z")).click();
System.out.println("Group ID: " + driver.findElement(By.xpath(".//*[@id=z]")));
鉴于u
的值为2而List28
给出了返回2。
是否可以像这样运行点击xpath
driver.findElement(By.xpath(".//*[@id=z")).click();
答案 0 :(得分:0)
是的,可以使用String.format()
String xpathExpression = String.format(".//*[@id='%s']", z);
driver.findElement(By.xpath(xpathExpression)).click();
或只是
driver.findElement(By.xpath(".//*[@id='"+z+"']")).click();