与这个问题有关。 Reload DOM element in selenium webdriver after some new tag added。但我想更进一步。我有一个表,基本上可以将元素降低到行级别。单击它时,它将在其行中打开另一个表。然后,我想从其中具有新表的行的webelemnt中获取该表。我不想遍历行的主表才能到达刚打开的行。我需要这样做吗,还是有某种方式可以用已更新的内容重新加载已加载的元素?
var section = Driver.Instance.FindElement(By.TagName("tbody"));
var table = section.FindElement(By.Id("UP2"));
//set the values and get the new calculation
var rows = table.FindElements(By.TagName("tr"));
var rowCount = 0;
foreach (var row in rows)
{
if (rowCount > 0)
{
var columns = row.FindElements(By.TagName("td"));
columns[1].Click(); //Where it expands the new table
Thread.Sleep(2000);
WebDriverWait wait = new WebDriverWait(Driver.Instance, new TimeSpan(10));
var testTable = row.FindElement(By.TagName("table"));
var testRows = testTable.FindElements(By.TagName("tr"));
foreach (var testRow in testRows)
{
//trying to get the second table
var testColumns = testRow.FindElements(By.TagName("td"));
}