1

I am trying to edit the message body area of outlook mail. The steps I have followed so far are,

  1. Login to outlook web app
  2. Double click and open the mail (the mail is opened in a seperate window)
  3. 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 tag inside the frame.
  4. Click Forward button
  5. New content is loaded in the same window (DOM gets refreshed) with message body,to, subject areas etc are enabled to edit.
  6. Edit the to and subject fields (these are in the header section)
  7. Edit the mail body area (this is also given inside a iframe as in previous view)
  8. Switch to iframe
  9. Try to find the 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"));
  • Need your HTML code – Yu Zhang Jan 12 '18 at 9:08
  • Add your code what hv you tried so far? There may be some chances in the switching iframe... – Bharat Mane Jan 12 '18 at 10:25
  • try just using `findElement('frame#ifBdy html') although html seems odd tag within frame so maybe try a different element within the html – Michael Durrant Jan 12 '18 at 12:21
  • Did you try to put a wait before finding the html tag? – Alok Jan 13 '18 at 3:42
2

In your case I think you should wait for the webelement to be visible before you try to find it.

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("tag_name")));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.