1

当前的 gmail UI 已更改,它在弹出的 DIV 中打开,并且每个新的撰写窗口的 ID 参数都在更改。任何人都可以尝试给我代码吗?

4

4 回答 4

4

您可以使用 XPath 完成所有操作(使用 查找By.xpath("xpath expression")):

  • 打开gmail页面
  • 像往常一样登录
  • 单击撰写按钮(其 XPath 表达式"//div[text()='COMPOSE']":)
  • (将弹出电子邮件对话框)
  • 在“收件人”文本区域中键入(发送键)地址:"//textarea[@name='to']"
  • 键入(发送键)主题到“主题”输入:"//input[@name='subjectbox']"
  • 将电子邮件内容键入(发送键)到可编辑的 div:("//div[@class='gmail_default']""//div[@aria-label='Message Body']"),因为他们似乎最近更改了 HTML)
  • 点击发送:"//div[text()='Send']"
于 2013-04-21T22:27:18.440 回答
0

我找到了以下解决方案:

<tr>

<td>setTimeout</td>
<td>3000</td>
<td></td>

</tr>

< !--open 命令通常等待 30 秒,所以我们现在要求它只等待 3 秒-->

<tr>

<td>open</td>
<td>/mail/u/0/?shva=1#inbox?compose=new</td>
<td></td>

</tr>

<tr>

<td>type</td>
<td>//table/tbody/tr[1]/td[2]/div/div/textarea</td>
<td>McKiran@example.com</td>

</tr>

<tr>

<td>type</td>
<td>name=subjectbox</td>
<td>Test</td>

</tr>

<tr>

<td>type</td>
<td>class=editable LW-avf</td>
<td>Hi All<br/>Hope the test is successful. <br/><br/><i> Lovingly, </i></br><b>McKiran.</b></td>

</tr>

<tr>

<td>click</td>
<td>class=T-I J-J5-Ji aoO T-I-atl L3</td>
<td></td>

</tr>

于 2013-04-22T09:37:30.987 回答
0

使用 selenium webdrier

去扔下面的链接

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

于 2014-01-29T06:59:02.180 回答
0

public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver","D:\Selenium\SeleniumWork\seleniumDrivers\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get(" https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/#identifier "); if(driver.findElement(By.xpath(".// [@id='Email']")).isEnabled()) { driver.findElement(By.xpath(".//[@id='Email']")).sendKeys("youremailid"); driver.findElement(By.xpath(".//*[@id='next']")).click(); } 线程.sleep(5000); WebElement menu = driver.findElement(By.xpath(".//input[@type='password']")); if(menu.isEnabled()) {

        System.out.println("Hello world");
         menu.sendKeys("emailidpassword");
        driver.findElement(By.xpath(".//*[@id='signIn']")).click();
    }
     Thread.sleep(5000);
     driver.findElement(By.xpath(".//div[contains(text(),'COMPOSE')]")).click();
     Thread.sleep(5000);
     driver.findElement(By.xpath("//textarea[@name='to']")).sendKeys("@gmail.com");
 driver.findElement(By.xpath("//input[@name='subjectbox']")).sendKeys("Sample");

driver.findElement(By.xpath("//div[@aria-label='Message Body']")).sendKeys("你好,这是简单的消息"); driver.findElement(By.xpath("//div[text()='Send']")).click();

}

于 2017-01-23T14:11:14.027 回答