如何从 Selenium 的 gmail 收件箱中单击特定的电子邮件?

我想点击特定的电子邮件,在这种情况下我应该怎么做?我看到有一个具有多个索引的 Webtable,我选择 1 &点击它.有没有人有代码如何处理 WebDriver 中的 webTables?在下面的屏幕中查看确切的情况 -http://screencast.com/t/XRbXQVygNkN6

I hv to click on a particular email, in that case what should I do? I seen there is a Webtable with multiple indexes, I hv to select 1 & click on it. does anyone have code how to handle webTables in WebDriver? See exact situation in below screen- http://screencast.com/t/XRbXQVygNkN6

我正在尝试使用以下代码 - 请建议我完成其余操作.

I was trying with below code -Plz suggest me for rest of the action.

gmail登录后-

第一次点击收件箱链接--->>然后是促销--->>然后我点击特定的电子邮件

1st Ihv clicked on inbox link--->>then Promotions--->>then I hv to click on particular email

WebElement PromotionsSection =driver.findElement(By.xpath("//div[contains(@id,':2y')]"));
PromotionsSection.click();

WebElement email=driver.findElement(By.xpath(".//*[@id=':1g4']/b"));
email.click();

推荐答案

认为你登录后在页面中.现在使用下面的代码:

think that u r in page after login. Now use the below code:

List<WebElement> email = driver.findElements(By.cssSelector("div.xT>div.y6>span>b"));

for(WebElement emailsub : email){
    if(emailsub.getText().equals("Your Subject Here") == true){

           emailsub.click();
           break;
        }
    }

如果它与主题字符串匹配,这只会点击你的邮件.

this will just click on ur mail if it matches the subject string.

相关文章