我正在尝试计算Gmail中所有邮件的数量以及">"使用Selenium,WebDriver无法找到转到旧电子邮件的按钮。由于它是使用div标签开发的,我只能使用Xpath但没有运气。请帮忙吗?
我的代码片段如下:
int allmails = 0;
int mails = 0;
do
{
WebElement table = obj.findElement(By.xpath("/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div[2]/div[1]/div[1]/div/div/div[4]/div[1]/div/table/tbody"));
List<WebElement> rows = table.findElements(By.tagName("tr"));
mails = rows.size();
allmails = allmails + mails;
if (obj.findElement(By.xpath("/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div[1]/div[2]/div[1]/div[2]/div[1]/span/div[3]")).getAttribute("aria-disabled").equals(""))
{
System.out.println("Total Emails", +allmails);
break;
}
else
{
obj.findElement(By.xpath("/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div[1]/div[2]/div[1]/div[2]/div[1]/span/div[3]")).click();
Thread.sleep(2000);
}
}while(2>1);
obj.close();
}
}