I cannot access elements inside of an iframe, I have tried the call:

IWebElement iframeSwitch = driver.FindElement(By.XPath("//iframe[contains(@id, 'contentIFrame1')and contains (@title, 'Content Area')]"));

This is a sample of the HTML for the Table

<table id="hlx_markertemplateid_lookupTable" class="ms-crm-Lookup" cellspacing="0" cellpadding="0" lookupid="hlx_markertemplateid" style="width: 100%; table-layout: fixed;" aria-labelledby="hlx_markertemplateid_c hlx_markertemplateid_w" controlmode="normal">

This is a sample of the td

<td valign="top">
 <div id="hlx_markertemplateid_lookupDiv" class="ms-crm-Lookup ms-crm-InlineLookupEdit ms-crm-Hidden-NoBehavior" role="list" ime-mode="auto" tabindex="0" style="width: 0px;">
  <ul class="ms-crm-InlineLookupEdit"></ul>
 <label class="ms-crm-Hidden-NoBehavior" for="hlx_markertemplateid_ledit">Marker Template Required</label>
 <input id="hlx_markertemplateid_ledit" class="ms-crm-InlineInput ms-crm-InlineLookupEdit" type="text" ime-mode="auto" maxlength="1000" style="ime-mode: auto;">

It seems like the iframe switch is successful(because there are no errors for that call) but I cannot access any of the content on the iframe. Thanks for your suggestions ahead of time.

  • You get the standard element not found for id hlx_markertemplateid_ledit?
    – EGHM
    Oct 13 '15 at 2:00
  • 1
    are you getting any exception? Oct 13 '15 at 5:47
  • Element not found
    – DEnumber50
    Oct 13 '15 at 18:41

I could send the text "Test" to the input text box inside iFrame. I used findById . Code is in Java but you can modify accordingly for C#.

WebElement iframeSwitch = driver.findElement(By.id("contentIFrame1"));

I faced the similar issue, so used the following approach:

actionObject = new Actions(firefoxDrvrInstance); 
actionObject.MoveToElement(find element here).Perform(); 
firefoxDrvrInstance.FindElement(blah blah).Click(); 
firefoxDrvrInstance.SwitchTo().Frame(firefoxDrvrInstance.FindElement(blah blah));

let me know if anything is not clear here...

This code is in C#.

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.