0

在此处输入图像描述有人可以帮助我如何使用 selenium 命令在 Gmail/Yahoomail 中调用撰写屏幕。

尝试使用以下命令。

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

4 回答 4

2

您可以使用Selenium IDE. 只需在 SIDE 中记录整个场景并执行以下步骤

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

现在,您可以看到您所做的场景的确切 Selenium RC 代码,并将其复制并粘贴到任何 IDE 中并使用它。

一个明智的建议是,selenium RC 已被弃用,RC 没有进一步的发展。未来已来Selenium WebDriver。请合并到 WebDriver。

编辑:

试试这个代码:

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

它可能会帮助你。

侧面屏幕截图:

在此处输入图像描述

于 2013-02-11T04:25:46.023 回答
2

您可以使用 webdriver 并轻松地从 gmail/yahoo 调用撰写邮件屏幕。请看下面的代码:

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

`

于 2013-02-11T07:10:18.413 回答
0

使用 Java 在 Selenium-RC 中调用 Gmail 的撰写屏幕,如下所示:

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

使用 Java 在 Selenium-RC 中调用 Yahoomail 的撰写屏幕,如下所示:

selenium.click("id=global_compose_top");

以下是 gmail 的 Selenium WebDriver Java 代码:

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

以下是 yahoo mail 的 Selenium WebDriver Java 代码:

driver.findElement(By.id("global_compose_top")).click();
于 2013-04-03T09:20:48.380 回答
-1

使用硒 wrbdriver

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

这里是在 gmail 中撰写邮件的完整代码

于 2014-01-29T06:45:58.347 回答