我在自动化分页测试时遇到问题。我的代码能够遍历第一页上的表格,如果“未找到搜索元素”,还可以单击下一页。但是,问题在于第二页没有保存/获取表的数据。尽管使用的表类对于所有页面都是静态的。请帮我解决这个问题。这是我的代码块:
IWebElement pagingInfo = webDriver.FindElement(By.ClassName("Dj")); //Getting text from Page info in the form of "1-emailsPerPage of totalNumberOfEmails"
string[] stringArray = pagingInfo.Text.Split(' ');
int totalNumberOfEmails = Convert.ToInt32(stringArray[2]);
int emailsPerPage = Convert.ToInt32(stringArray[0].Substring(2));
int clickCount = totalNumberOfEmails / emailsPerPage;
for (int i = 0; i <= clickCount; i++)
{
IWebElement tableInbox = webDriver.FindElement(By.ClassName("Cp")).FindElement(By.ClassName("F"));
IList<IWebElement> rowsCollection = tableInbox.FindElements(By.TagName("tr"));
foreach (IWebElement row in rowsCollection)
{
IList<IWebElement> columnCollection = row.FindElements(By.TagName("td"));
if (columnCollection[5].Text.Contains("Fwd: Security"))
{
Console.WriteLine("Record found");
recordFound = true;
break;
}
}
if (recordFound == true)
break;
webDriver.FindElement(By.ClassName("ar5")).FindElement(By.ClassName("amJ")).Click();
Thread.Sleep(5000);
}
if (recordFound == true)
Console.WriteLine("Record Found");
else
Console.WriteLine("Record Not Found");
请帮忙!!提前致谢 :)