I am trying to edit the message body area of Outlook mail. The steps I have followed so far are,
- Login to Outlook web app
- Double click and open the mail (the mail is opened in a separate window)
- Select the window and extract mail details.
Mail body content is provided inside a iframe. Hence I switch to iframe and read the innerHtml of the
<html>
tag inside the frame. - Click Forward button
- New content is loaded in the same window (DOM gets refreshed) with message body, to, subject areas etc are enabled to edit.
- Edit the to and subject fields (these are in the header section)
- Edit the mail body area (this is also given inside a iframe as in previous view)
- Switch to iframe
- Try to find the
<html>
element inside the frame
But my script if failing at step 9, throwing NoSuchElementException. But before clicking forward and after clicking forward, the element structure of in DOM are the same. I have been looking for a solution far this for the past two days. Some help here would be great.
Before clicking forward:
<html>
.....
<div id="divBdy" class="messageBody" style="top: 163px;">
<iframe id="ifBdy" allowtransparency="" class="w100" frameborder="0" src="xxx/scripts/premium/blank.htm" tabindex="-1" data-_contentdocument="0" style="">
<html>
......
</html>
</iframe>
</div>
....
</html>
After clicking forward:
<html>
.....
<div id="divBdy" class="messageBody" style="top: 163px;">
<iframe id="ifBdy" class="w100" frameborder="0" src="xxxx/scripts/premium/blank.htm" data-_contentdocument="0"
<html>
......
</html>
</iframe>
</div>
....
</html>
Sorry, I am unable to provide screen shots. Elements above this div can be accessed.
Frame selection:
driver.switchTo().frame(driver.findElement(By.id("ifBdy")));
System.out.println(driver.getPageSource());
driver.findElement(By.tagName("html"));