【问题标题】:how to clear list of email in yopmail.com如何清除 yopmail.com 中的电子邮件列表
【发布时间】:2017-10-09 09:08:15
【问题描述】:

嗨,我有使用 selenium 的场景需要自动创建 yopmail 用户帐户,因此对于每次下一次迭代,如果我尝试创建新帐户,我需要清除我之前输入的电子邮件。所以为此我尝试了几个选项,我阅读你的博客,但它没有多大帮助...... 尝试过的选项 1.element.clear() 方法 2.使用键选择文本并删除。

我不需要上述方法请告诉我第三种方法,我们直接清除整个历史使用在 yopmail 下拉菜单中指定为“clearlist”的选项。

问题:当我 click() 邮箱图标时,下拉菜单正在消失,因为出现 elementnot visible 异常。

使用的代码

FirefoxDriver d = new FirefoxDriver();
    d.get("http://yopmail.com");
    try{
    d.findElement(By.xpath("//*[@id='login']")).sendKeys("mpqa");
     Thread.sleep(1000);
     d.findElement(By.xpath("//*[@id='f']/table/tbody/tr[1]/td[3]/input")).click();  

       Thread.sleep(1000);
       WebElement mailboxIcon=d.findElement(By.xpath("//*[@id='menucpt']/ul/li[1]/center/span"));          
       Thread.sleep(1000);

    Actions builder = new Actions(d);  
    builder.moveToElement(mailboxIcon).build().perform();
    mailboxIcon.click();
    WebDriverWait wait = new WebDriverWait(d, 15); 
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='f']/table/tbody/tr[1]/td[1]/a")));      

       WebElement clearList=d.findElement(By.xpath("//*[@id='menucpt']/ul/li[3]/a"));
       clearList.click();

请查看附件图片 http://imgur.com/lxlONYX

【问题讨论】:

    标签: selenium selenium-webdriver webdriver selenium-chromedriver


    【解决方案1】:

    要清除列表,请使用此代码。它一定会为你工作

     driver.get("http://yopmail.com");
    driver.findElement(By.xpath(".//*[@id='login']")).sendKeys("si");
    driver.findElement(By.xpath("//*[@id='f']/table/tbody/tr[1]/td[3]/input")).click();
    driver.findElement(By.xpath("//a[@class='butcpt']")).click();
    driver.findElement(By.linkText("Clear list ")).click();
    

    如果您想清除收件箱,请使用以下代码。它会为你工作。`

        try{
    driver.findElement(By.xpath(".//*[@id='login']")).sendKeys("si");
    driver.findElement(By.xpath("//*[@id='f']/table/tbody/tr[1]/td[3]/input")).click(); 
    driver.switchTo().frame("ifinbox");// Actually the inbox mails are showing in an iFrame so first we have to switch to that iFrame to perform the further action.
    driver.findElement(By.xpath(".//*[@id='e0']")).click();// click on the select mail icon.
    driver.findElement(By.xpath("html/body/div[1]/table/tbody/tr/td[2]/a")).click();// click on the delete
    driver.findElement(By.linkText("Empty Inbox")).click();// click on the Empty Inbox.
    }
    

    【讨论】:

      【解决方案2】:

      这是因为您的 xpath 错误。

      WebElement mailboxIcon=d.findElement(By.xpath("//a[@class='butcpt']"));   
      

      更换它并享受。

      【讨论】:

        猜你喜欢
        • 2021-06-29
        • 1970-01-01
        • 2012-05-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-23
        • 1970-01-01
        • 2019-04-13
        相关资源
        最近更新 更多