如何单击Selenium中gmail收件箱中的特定电子邮件? [英] How to click on a Particular email from gmail inbox in Selenium?

查看:67
本文介绍了如何单击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

我正在尝试使用以下代码-Plz建议我进行其余操作.

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.

这篇关于如何单击Selenium中gmail收件箱中的特定电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆