Domanda

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");
È stato utile?

Soluzione

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()

`

Altri suggerimenti

You can easily achieve this by using Selenium IDE. Just record the whole scenario in the SIDE and do the below steps

1. GoTo Options
2. Format
3. Click the Java/ Junit4/ Remote Control option.

Now you can see the exact Selenium RC code for the scenario you did and copy and paste it in to any IDE and make use of it.

One advisable suggestion, selenium RC is deprecated and there is no further development on RC. The future is on Selenium WebDriver. Please incorporate in to WebDriver.

Edited:

Try this code:

    //Assume driver is initialized properly some where else.
    driver.get("http://www.gmail.com/");
    driver.findElement(By.id("Email")).clear();
    driver.findElement(By.id("Email")).sendKeys("UserName");
    driver.findElement(By.id("Passwd")).clear();
    driver.findElement(By.id("Passwd")).sendKeys("Password");
    driver.findElement(By.id("signIn")).click();
    //Add some wait. Use Selenium Implicit wait and Explicit wait.
    Thread.sleep(5000);
    driver.findElement(By.xpath("//div[2]/div/div/div/div[2]/div/div/div/div/div")).click();
    driver.findElement(By.id("gbi4t")).click();
    driver.findElement(By.id("gb_71")).click();

It may help you.

SIDE Screen shot:

enter image description here

To invoke Compose screen of Gmail in Selenium-RC using Java as below:

selenium.click("//div[text()='COMPOSE']");

To invoke Compose screen of Yahoomail in Selenium-RC using Java as below:

selenium.click("id=global_compose_top");

The following is the Selenium WebDriver Java code for gmail:

driver.findElement(By.xpath("//div[text()='COMPOSE']")).click();

The following is the Selenium WebDriver Java code for yahoo mail:

driver.findElement(By.id("global_compose_top")).click();

Use selenium wrbdriver

http://ngowda.blogspot.in/2014/01/uploading-file-in-e-commerce-site-using.html

here full code of compose a mail in gmail

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top