【发布时间】:2020-08-06 17:01:53
【问题描述】:
我正在尝试按其名称获取某行,然后单击该元素中的一个元素。 我要做的是:
// searching for a row with the given name of the column content
WebElement row = driver.findElement(By.xpath("//div[contains(text(), 'John Smith']//ancestor::div[@class='row']"));
//clicking button within the row
Webelement button = row.findElement(By.xpath("//button[@class='Click']"))
它不是这样工作的,它总是单击表格第一行中的按钮。附言WebElement row 本身被正确识别并找到正确的行。仅当我想在所需行中搜索按钮时。对此有何建议?
【问题讨论】: