我有一种在Gmail中撰写邮件的方法,我正面临着切换框架以在邮件正文中书写的问题。
在这种情况下如何识别框架?
public Mail composeMail(){
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.elementToBeClickable(compose));
compose.click();
fullScreen.click();
recipients.sendKeys("paliwal.sumit31@gmail.com");
subject.sendKeys("Gmail_Automation - Demo Mail");
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@name='__HC_94253229']")));
driver.switchTo().activeElement().sendKeys("test message");
}
HTML代码:
<iframe ng-non-bindable="" frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" style="border: none; margin-bottom: -4px; width: 340px; height: 128px;" tabindex="-1" vspace="0" width="100%" id="" name="__HC_94253229" src="https://contacts.google.com/widget/hovercard/v/2?authuser=0&origin=https%3A%2F%2Fmail.google.com&usegapi=1&jsh=m%3B%2F_%2Fscs%2Fabc-static%2F_%2Fjs%2Fk%3Dgapi.gapi.en.CUp85wbT4DI.O%2Frt%3Dj%2Fd%3D1%2Frs%3DAHpOoo-XBQda2DFvo9hxbj_dGnCV84SJMA%2Fm%3D__features__#id=__HC_94253229&_gfid=__HC_94253229&parent=https%3A%2F%2Fmail.google.com&pfname=&rpctoken=29482633"></iframe>
.
.
.
.
.
<div id=":o3" class="Ar Au" style="display: block;"><div id=":116" class="Am Al editable LW-avf" hidefocus="true" aria-label="Message Body" g_editable="true" role="textbox" aria-multiline="true" contenteditable="true" tabindex="1" style="direction: ltr; min-height: 80px;"><br></div></div>
请仔细检查在浏览器中检查“撰写邮件HTML”代码。