Search code examples
seleniumgmailselenium-rcyahoo-mail

Unable to invoke compose screen in Gmail/Yahoomail using selenium


enter image description hereCan some one help me out how can i invoke compose screen in Gmail/Yahoomail using selenium commands.

Tried with the following commands.

selenium.click("href=compose link");
selenium.click("name=Compose");

Solution

  • you can use webdriver and easily can invoke compose mail screen from gmail/yahoo. See the code below:

    from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select import selenium.webdriver.support.ui as ui from selenium.common.exceptions import NoSuchElementException import unittest, time, re, os import HTMLTestRunner import xlrd

    class gmail(unittest.TestCase):
        def setUp(self):
            self.driver = webdriver.Firefox()
            self.driver.implicitly_wait(30)
            self.base_url = "http://gmail.com"
            self.verificationErrors = []
    
    
        def test_gmail_login(self):
            driver=self.driver
            driver.get(self.base_url +"/")
            driver.find_element_by_xpath("//*[@id='Email']").clear()
            print "1. enter user name in username text field"
            driver.find_element_by_xpath("//*[@id='Email']").send_keys("xxxx")
            driver.find_element_by_xpath(".//*[@id='Passwd']").clear()
            print "2.enter password in password text field"
            driver.find_element_by_xpath(".//*[@id='Passwd']").send_keys("xxxx")
            print " 3. Click signIn button. it has redirect to corresponding gmail home page"
            driver.find_element_by_xpath("//*[@id='signIn']").click()
            print "click compose mail button"
            driver.find_element_by_xpath("//*[@id=':b7']/div/div").click()
            driver.save_screenshot('/compose.png')
            try:
             driver.find_element_by_xpath("//*[@class='z0']/div").click()
    

    `