Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Selenium IDE自动化新的gmail用户界面来发送电子邮件?_Selenium_Ide_Gmail - Fatal编程技术网

如何使用Selenium IDE自动化新的gmail用户界面来发送电子邮件?

如何使用Selenium IDE自动化新的gmail用户界面来发送电子邮件?,selenium,ide,gmail,Selenium,Ide,Gmail,当前的gmail用户界面已经改变,它在弹出的DIV中打开,每个新的组合窗口的ID参数都在改变。有人能告诉我代码吗?您可以使用XPath查找并使用By.xpathxpath表达式: 打开gmail页面 照常登录 单击compose按钮及其XPath表达式://div[text='compose'] 将弹出电子邮件对话框 在To text区域键入send key和address://textarea[@name='To'] 键入将主题发送到主题输入://input[@name='subjectbox

当前的gmail用户界面已经改变,它在弹出的DIV中打开,每个新的组合窗口的ID参数都在改变。有人能告诉我代码吗?

您可以使用XPath查找并使用By.xpathxpath表达式:

打开gmail页面 照常登录 单击compose按钮及其XPath表达式://div[text='compose'] 将弹出电子邮件对话框 在To text区域键入send key和address://textarea[@name='To'] 键入将主题发送到主题输入://input[@name='subjectbox'] 键入send key将电子邮件内容发送到可编辑的div://div[@class='gmail\u default']或//div[@aria label='Message Body'],因为他们似乎最近更改了HTML 点击send://div[text='send']
您可以使用XPath查找并使用By.xpathxpath表达式执行所有操作:

打开gmail页面 照常登录 单击compose按钮及其XPath表达式://div[text='compose'] 将弹出电子邮件对话框 在To text区域键入send key和address://textarea[@name='To'] 键入将主题发送到主题输入://input[@name='subjectbox'] 键入send key将电子邮件内容发送到可编辑的div://div[@class='gmail\u default']或//div[@aria label='Message Body'],因为他们似乎最近更改了HTML 点击send://div[text='send']
我找到了以下解决方案:

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


我找到了以下解决方案:

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

使用硒烘干机

去扔下面的链接

使用硒烘干机

去扔下面的链接


public static void mainString[]args引发InterruptedException{ System.setPropertywebdriver.chrome.driver,D:\Selenium\SeleniumWork\seleniumDrivers\chromedriver.exe; WebDriver=新的ChromeDriver; driver.manage.window.maximize; driver.get; ifdriver.findElementBy.xpath./[@id='Email'].isEnabled { driver.findElementBy.xpath./[@id='Email'].sendKeysyouremailid; driver.findElementBy.xpath./*[@id='next']; } 线程5000; WebElement menu=driver.findElementBy.xpath//输入[@type='password']; ifmenu.i已启用 {

        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.findElementBy.xpath//div[@aria label='Message Body'].sendKeysHI这是一条简单的消息; driver.findElementBy.xpath//div[text='Send']。单击


}

公共静态无效主字符串[]args引发中断异常{ System.setPropertywebdriver.chrome.driver,D:\Selenium\SeleniumWork\seleniumDrivers\chromedriver.exe; WebDriver=新的ChromeDriver; driver.manage.window.maximize; driver.get; ifdriver.findElementBy.xpath./[@id='Email'].isEnabled { driver.findElementBy.xpath./[@id='Email'].sendKeysyouremailid; driver.findElementBy.xpath./*[@id='next']; } 线程5000; WebElement menu=driver.findElementBy.xpath//输入[@type='password']; ifmenu.i已启用 {

        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.findElementBy.xpath//div[@aria label='Message Body'].sendKeysHI这是一条简单的消息; driver.findElementBy.xpath//div[text='Send']。单击


}

谢谢这个acdcjunior,但是内容框由iframe提供,类被更改为class=class=editable LW avf。无论如何,这与我自己发现的类似。实际上,我在定位to字段的元素时遇到了一些问题。但是现在问题解决了。@MCKiran好的,很好!但是你知道如何通过XPath、ri获取元素ght?使用webdriver会让你的生活更轻松。答案很好!如何添加附件?感谢这个acdcjunior,但是内容框由iframe提供,类被更改为class=class=editable LW avf。无论如何,这与我自己发现的类似。实际上,我在定位to字段的元素时遇到了一些问题。但是现在就解决了。@MCKiran好的,很好!但是你知道如何通过XPath获取元素,对吗?使用webdriver会让你的生活更轻松。答案很好!如何添加附件?请格式化你的代码并添加解释,说明你提供的代码为什么工作。谢谢!请格式化你的代码并添加解释,说明你提供的代码为什么工作谢谢,谢谢!
<td>type</td>
<td>//table/tbody/tr[1]/td[2]/div/div/textarea</td>
<td>McKiran@example.com</td>
<td>type</td>
<td>name=subjectbox</td>
<td>Test</td>
<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>
<td>click</td>
<td>class=T-I J-J5-Ji aoO T-I-atl L3</td>
<td></td>
        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");