Not able to click on 'Compose' button in gmail account

734 views
Skip to first unread message

pratika

unread,
Aug 13, 2014, 8:45:29 AM8/13/14
to webd...@googlegroups.com
Hi

In gmail account i need to click on 'compose'  but its not able to identify this element
using these commands but not working
driver.findElement(By.xpath("//div[@id=':51']/div/div")).click();
    driver.findElement(By.xpath("//div[contains(text(),'COMPOSE']")).click();


There is no switching of Frame as far as I concerned.

Kindly suggest what could be the issue.

Thanks in advance!


Krishnan Mahadevan

unread,
Aug 13, 2014, 8:54:04 AM8/13/14
to webdriver
And why would you want to do that ? Can you please elaborate your usecase ?

If you are doing this as part of learning how to use WebDriver, then I would sincerely recommend that you stop using GMail as a test application for learning automation. GMail is very complex and more than learning anything you will only be trying to figure out work arounds of dealing with its complex structure. You should only be automating GMail if you are working for Google!

If you are basically trying to simulate a mailing action which is what led you to do this, then you are using the wrong tool for the job. You are better off using JavaMail APIs for all mail interactions.





Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

darrell

unread,
Aug 14, 2014, 8:30:33 AM8/14/14
to webd...@googlegroups.com
Krishnan has an important question to consider. If you are trying to automate Gmail so you have a service to use for testing there are a number of reasons this is a bad idea. The most important reasons are:
  1. Automating Gmail is difficult and you aren't on the Gmail team, therefore you won't know they change things before your tests start failing
  2. When doing test automation you want email to be immediate but using Gmail could result in delays because it is a real email service
  3. If you are testing an application before it is released to the public and using Gmail to test it then you are sending private information from the application to a public service, i.e. Gmail. You could be breaching security or a NDA
You can use something like mountebank to mock out an SMTP server.

If you are just practicing and want to use Gmail as something to automate, first note that Gmail is so far from a static website that automating it without inside information can be very difficult. That said, look at two or more Gmail accounts and see if there are similarities between the DOM on the two accounts. Log out and log in to the same account then see if there are similarities between the DOM. You will need to be able to spot the patterns which are unique and consistent. For example, I believe the best locator for the Compose button in Gmail is:

    WebElement composeButton = driver.findElement(By.cssSelector("[gh='cm']"));
    composeButton.click();

I would assume that people on the Gmail team understand that there will always be one element which has the above attribute for the Compose button. If it changes however you tests will fail. In some cases the Gmail team but have a database (spreadsheet, property file, whatever) of locators and they change the locators every so often to throw people like us. For the people on the team, if the application and the tests are using the same database of locators then when they change the database, all the tests will keep working but since we don't have access to the database, our tests will fail. Just one possibility for why automating an application you are not working on can be fraught with problems.
Reply all
Reply to author
Forward
0 new messages