Unable to select the all unread mail in Gmail through selenium

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to select the all unread mail in Gmail through selenium

Avinash Mavi
I am using the filter dropdown to select the Unread mails.

Selenium Code:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class testing {
public static void main(String[] args) throws InterruptedException {
     WebDriver driver = new FirefoxDriver();
        String baseUrl = "https://www.gmail.com";
                
        driver.get(baseUrl);
       
        driver.findElement(By.id("identifierId")).sendKeys("**********@gmail.com");
        
        driver.findElement(By.id("identifierNext")).click();
        
        Thread.sleep(3000);
        
        driver.findElement(By.xpath(".//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("*****");
        
        driver.findElement(By.id("passwordNext")).click();
        
        Thread.sleep(4000);

        driver.findElement(By.xpath("//*[@id=':2t']/div[2]")).click();

        Thread.sleep(3000);
       
        // to click the unread mail in the dropdown

        WebElement value=driver.findElement(By.xpath("//div[7]/div/div[4]/div"));
        Actions act=new Actions(driver);
        act.moveToElement(value).build().perform();
        value.click();

        Thread.sleep(2000);         
             
        //driver.close();
        //System.exit(0);
      
}

}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c1594047-9815-458e-85b6-803f44a06ace%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to select the all unread mail in Gmail through selenium

Doug Dragon
Why are you automating Gmail? Unless you work on the Gmail team, I would think you'd much rather want to use Gmail's API.

On Wednesday, May 31, 2017 at 10:32:31 AM UTC-4, Avinash Mavi wrote:
I am using the filter dropdown to select the Unread mails.

Selenium Code:

import <a href="http://org.openqa.selenium.by/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Forg.openqa.selenium.by%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH3N8mrMHhLr8Y42yXGfsGSRJHkww&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Forg.openqa.selenium.by%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH3N8mrMHhLr8Y42yXGfsGSRJHkww&#39;;return true;">org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class testing {
public static void main(String[] args) throws InterruptedException {
     WebDriver driver = new FirefoxDriver();
        String baseUrl = "<a href="https://www.gmail.com/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.gmail.com/&#39;;return true;" onclick="this.href=&#39;https://www.gmail.com/&#39;;return true;">https://www.gmail.com";
                
        driver.get(baseUrl);
       
        driver.findElement(By.id("identifierId")).sendKeys("**********@<a href="http://gmail.com/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://gmail.com/&#39;;return true;" onclick="this.href=&#39;http://gmail.com/&#39;;return true;">gmail.com");
        
        driver.findElement(By.id("identifierNext")).click();
        
        Thread.sleep(3000);
        
        driver.findElement(By.xpath(".//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("*****");
        
        driver.findElement(By.id("passwordNext")).click();
        
        Thread.sleep(4000);

        driver.findElement(By.xpath("//*[@id=':2t']/div[2]")).click();

        Thread.sleep(3000);
       
        // to click the unread mail in the dropdown

        WebElement value=driver.findElement(By.xpath("//div[7]/div/div[4]/div"));
        Actions act=new Actions(driver);
        act.moveToElement(value).build().perform();
        value.click();

        Thread.sleep(2000);         
             
        //driver.close();
        //System.exit(0);
      
}

}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8bb011e9-6f3e-4e25-9d7b-1ef4216ffd21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to select the all unread mail in Gmail through selenium

Monika Singhal
In reply to this post by Avinash Mavi
Hi,

I see the xpath which you have used for selecting unread option is incorrect. You have to modify that xpath. 

Modification which can be made in the xpath:

       WebElement value=driver.findElement(By.xpath("//div[@selector='unread']/div"));

Thanks & Regards,
Monika



On Wednesday, May 31, 2017 at 8:02:31 PM UTC+5:30, Avinash Mavi wrote:
I am using the filter dropdown to select the Unread mails.

Selenium Code:

import <a href="http://org.openqa.selenium.by/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Forg.openqa.selenium.by%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH3N8mrMHhLr8Y42yXGfsGSRJHkww&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Forg.openqa.selenium.by%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH3N8mrMHhLr8Y42yXGfsGSRJHkww&#39;;return true;">org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class testing {
public static void main(String[] args) throws InterruptedException {
     WebDriver driver = new FirefoxDriver();
        String baseUrl = "<a href="https://www.gmail.com/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.gmail.com/&#39;;return true;" onclick="this.href=&#39;https://www.gmail.com/&#39;;return true;">https://www.gmail.com";
                
        driver.get(baseUrl);
       
        driver.findElement(By.id("identifierId")).sendKeys("**********@<a href="http://gmail.com/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://gmail.com/&#39;;return true;" onclick="this.href=&#39;http://gmail.com/&#39;;return true;">gmail.com");
        
        driver.findElement(By.id("identifierNext")).click();
        
        Thread.sleep(3000);
        
        driver.findElement(By.xpath(".//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("*****");
        
        driver.findElement(By.id("passwordNext")).click();
        
        Thread.sleep(4000);

        driver.findElement(By.xpath("//*[@id=':2t']/div[2]")).click();

        Thread.sleep(3000);
       
        // to click the unread mail in the dropdown

        WebElement value=driver.findElement(By.xpath("//div[7]/div/div[4]/div"));
        Actions act=new Actions(driver);
        act.moveToElement(value).build().perform();
        value.click();

        Thread.sleep(2000);         
             
        //driver.close();
        //System.exit(0);
      
}

}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d82df489-b1ef-4e5d-b1d7-3eb90ba0ff28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.