打开并阅读带有Selenium/Katalon(Java)特定标题的电子邮件文本(来自Gmail)
我想:
- 打开Gmail
driver = new ChromeDriver();
driver.get("https://mail.google.com/mail/#inbox");
- 研究题目
driver.findElement(By.xpath("//input[@name='q']")).click();
driver.findElement(By.xpath("//input[@name='q']")).clear();
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("Title");
driver.findElement(By.cssSelector("button.gb_2e.gb_df > svg")).click();
- 打开并存储具有该标题的所有电子邮件的文本(可能位于不同的页面)
我怎么做
# 1 楼答案
好的,在你搜索了文本之后,我想下一件事应该是找出如何单击当前页面上的每个元素,然后处理分页
对我来说,以下CSS选择器可以找到页面上的所有电子邮件元素:
例如,如果该页面上有50个结果,它将返回一个包含这50个WebElement的数组
现在,我们必须循环浏览电子邮件,点击每一封,然后点击。。。图标并下载电子邮件,然后返回到for循环中的主页
好的,现在我们只需要处理分页
在我看来,当启用时,进入下一页的插入符号图标由
但是,当按钮被禁用时,该选择器会找到两个元素。我认为这使得以下代码可以满足您的需求: