Issues in Login to gmail mail box.

313 views
Skip to first unread message

kcsel...@gmail.com

unread,
Feb 28, 2016, 1:09:16 AM2/28/16
to Selenium Users
Hi ,

i am writing a test case to open my gmail mail box by giving id and password. but test case fails. its very basic operation but am unable to fix this issue. can anyone please help me in that . below is the action am doing .

1) am logining using the below URL.
."https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier"

2 ) i am giving my id and then i am clicking next button.

3) in next page am trying to give password but at this point script fails. i tried with elements id, name and xpath but all fails. can anyone please help in this. my script is given below. 


public static void main(String[] args) {
   
        driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier");
        driver.manage().window().maximize();
        driver.findElement(By.id("Email")).sendKeys("Myemail");
        driver.findElement(By.id("next")).click();
        driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("mypassword");
        driver.findElement(By.name("signIn")).click();       
        driver.close();   
       
    }

Shawn McCarthy

unread,
Feb 28, 2016, 9:25:25 AM2/28/16
to Selenium Users
I think the problem is that you are trying to use selenium to read emails. Use the Java Mail APIs instead.

natarajan ramanathan

unread,
Feb 28, 2016, 12:37:26 PM2/28/16
to Selenium Users
Hi

Your code is perfectly all right except for the case that the selenium is too fast in finding the password text element on the next page even before the page is completely loaded.
Adding a wait command after you click on next will resolve the problem and "myemail" is not an acceptable mail id. Also change the locator technique of log in button as By.id instead of By.name is the value corresponds to id.

public static void main(String[] args) throws InterruptedException 
{
    WebDriver driver=new FirefoxDriver();
        driver.findElement(By.id("Email")).sendKeys("selenium");
        driver.findElement(By.id("next")).click();
        Thread.sleep(1000);
        driver.findElement(By.xpath("//input[@id='Passwd']")).sendKeys("mypassword");
        driver.findElement(By.id("signIn")).click();        
        driver.close();    
        
}

Regards
Natarajan Ramanathan

mr. Selenide

unread,
Feb 28, 2016, 4:24:58 PM2/28/16
to Selenium Users
Hi!
Here you can find a working example of testing GMail. With detailed comments and video.

http://selenide.org/2014/12/28/how-to-test-gmail

manvendra kumar mishra

unread,
Feb 29, 2016, 1:27:26 AM2/29/16
to seleniu...@googlegroups.com
Hello,


instead adding wait time,set the driver implicit wait timeout. (driver.manage().timeouts().implicitlyWait(implicitWaitTimeOut, TimeUnit.SECONDS);)
And instead giving full url, u can give https://www.gmail.com.

public static void main(String[] args) {
    
        driver.get("https://www.gmail.com");
        driver.manage().timeouts().implicitlyWait(implicitWaitTimeOut, TimeUnit.SECONDS);

        driver.manage().window().maximize();
        driver.findElement(By.id("Email")).sendKeys("Myemail");
        driver.findElement(By.id("next")).click();
        driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("mypassword");
        driver.findElement(By.name("signIn")).click();        
        driver.close();    
        
    } 



Hope this works.


--
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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2f308cd4-f322-4baa-bd69-cef0e418157a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Manvendra Kumar MIshra
B.TECH Bioinformatics
Dr.D.Y.Patil University

Darshan Devanikar

unread,
Feb 29, 2016, 6:53:00 AM2/29/16
to Selenium Users
Use waits instead of Thread.sleep().
If Implicit does not work, go for explicit wait with visibility conditions of that particular pwd text box element.
Reply all
Reply to author
Forward
0 new messages