Dev / Iframe issue with uploading file

1 Answer 21 Views
Coded Tests Dialog Elements Frames
John
Top achievements
Rank 1
Iron
John asked on 16 Dec 2025, 07:22 AM

Iframe not always selecting Elements with upload, Dynamic drop down, text box, and OK button.  The Iframe is wrapped inside a DIV modal, here is the code I am using:

 

 

// Grabbing all the HTML DIV into a list showing the count.

            IList<HtmlDiv> PopUpList = Find.AllByXPath<HtmlDiv>("//div[@role='dialog']");

            iml.VerboseMsg($"Popup Element Count: {PopUpList.Count}");

 

// Grabbing the last DIV

            HtmlDiv lastPopUp;

            lastPopUp = PopUpList.Last();

 

 

            ArtOfTest.WebAii.Core.Browser t1_frame = lastPopUp.OwnerBrowser.Frames[0];

            iml.VerboseMsg($"Frame: {t1_frame.ToString()}");

            Assert.IsNotNull(t1_frame);

            t1_frame.WaitUntilReady();

            Element toggleOff = t1_frame.Find.ById("ContentPlaceHolder1_ASPxUploadControl1_TextBox0_FakeInput");

            ActiveBrowser.WaitUntilReady();

 

            t1_frame.Actions.Click(toggleOff);

            Element DocumentType = t1_frame.Find.ById("ContentPlaceHolder1_ddlDocType");

            t1_frame.Actions.SelectDropDown(DocumentType, 2);

            Element UploadFileOK = t1_frame.Find.ById("btnUpload");

            t1_frame.Actions.Click(UploadFileOK);

 

The code does not always work but it does work here and there. Any thoughts?

 

John

1 Answer, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 18 Dec 2025, 04:26 PM

Hello John,

Thank you for reaching out to Progress Telerik Test Studio technical support.
Regarding the intermittent nature of the failures, it is important to clarify that while Test Studio provides a robust framework for execution, we cannot provide debugging services or maintenance for custom C# code developed within coded steps. Custom solutions fall outside the scope of core product support.

However, based on the behavior you described where the code works "here and there," I can provide insight into the technical factors that typically cause such instability in automated scripts.

Potential Causes for Intermittent Failures

When a script functions inconsistently, it usually indicates a synchronization gap between the automation engine and the browser's rendering engine.

  • Race Conditions in the DOM: When a modal is invoked, the div and the iframe may exist in the DOM, but the content inside the iframe is still being fetched from the server. If the code attempts to find ContentPlaceHolder1_ASPxUploadControl1_TextBox0_FakeInput before the internal document is fully parsed, the lookup will fail.

  • Frame Index Volatility: You are currently using Frames[0]. If the application injects another iframe into the page dynamically, Frames[0] may no longer point to your target modal. Identifying the frame by its Name or Source URL is more reliable than using an index.


Recommended Troubleshooting Steps

To stabilize your custom implementation, we suggest the following diagnostic adjustments:

  1. Verify Frame Identity: Use a specific identifier for the frame.

  2. Implement Explicit Waits: Rather than relying on the page-level WaitUntilReady, use WaitForElement with a specific timeout (e.g., 5000ms). This allows the script to "poll" the DOM until the element is actually present.

  3. Add RefreshDomTree: Insert ActiveBrowser.RefreshDomTree() immediately after the modal appears to ensure the framework's cache is synchronized with the current state of the browser.

Hope that helps.

Regards,
Ivaylo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Coded Tests Dialog Elements Frames
Asked by
John
Top achievements
Rank 1
Iron
Answers by
Ivaylo
Telerik team
Share this question
or