Using Selenium 4.0 and Google Chrome 142 in a C# application, I have issues accessing resp. "finding" an element on my website. The HTML presented in the Chrome dev console is as follows (slightly shortened, anonymized and compacted):
<iframe id="mainframe" name="mainframe" frameborder="0" scrolling="auto" marginheight="0" marginwidth="0" width="100%" allowtransparency="true" onattributes="{"onload":"onLoadExzContentGetted(undefined);stopPerformanceMeasures();"}" style="visibility: visible; display: block; width: 890px; height: 561px;">
#document (https://example.org)
<html>
<head>text skipped, title and several metas and scripts tags</head>
<body marginwidth="0" marginheight="0" style="background-color: transparent; margin: 0px;">
<div id="WzTtDiV" style="visibility: hidden; position: absolute; overflow: hidden; padding: 0px; width: 0px; left: 0px; top: 0px;"></div>
<!-- I can't even find this element using FindElements, despite having switched to iFrame "mainframe" -->
<span id="messagebox"> </span>
<form name="GetInstructionOverviewActionForm" method="post" action="/example/getInstructionOverview.do" id="productOverviewForm">
<div class="cuiSwitchColor uwrNoFolderLines uwrNoTreeFolders">
<div class="cuiSwitchColor" id="ttOverview_container">
<table cellpadding="0" cellspacing="0" style="width:890px;" id="ttOverview_headingtable" class="uwrNoFolderLines uwrNoTreeFolders uwrTable uwrTableLayoutFixed uwrTreeTable">
<colgroup>
<col width="250">
<col width="40">
<col width="180">
<col width="40">
<col width="380">
</colgroup>
<tbody>
<tr class="uwrTableTitle" id="ttOverview_title">
<td class="uwrFirst uwrTb" colspan="5">
<div class="uwrTableTitlePadding">
<table style="width:100%;border:0px;" cellpadding="0" cellspacing="0" summary="">
<tbody>
<tr>
<td class="uwrJustFormat">
<div class="uwrTb">Blocks and instructions</div>
</td>
<td class="uwrJustFormat" style="text-align:right;">
<script type="text/javascript" language="Javascript">
function globalPrint(){ [........] }
</script>
<a onmouseup="uwrResetImage(this);" onmouseout="uwrResetImage(this);" style="text-decoration: none;" onmousedown="uwrPressImage(this);" href="javascript:globalPrint();" title="Print" class="cuiLink">
<script type="text/javascript" src="/example/uwFunctionIcon.js"></script>
<!-- skipped some script tags -->
<img src="https://example.org/print_active.gif" alt="example/print_active.gif" id="funciconGlobalPrint" title="Print" class="uwrFunctionIcon cuiTableFunctionIcon uwrFunctionIconInTitle">
</a>
<a onmouseup="uwrResetImage(this);" onmouseout="uwrResetImage(this);" style="text-decoration: none;" onmousedown="uwrPressImage(this);" href="https://example.org" title="Help" class="cuiLink" target="_blank">
<script type="text/javascript">uwrRegisterImage260('funciconGlobalHelp', '/example/contextsens_help_active.gif', '/example/contextsens_help_pressed.gif', '/example/contextsens_help_inactive.gif', 'example/contextsens_help_toggle.gif');</script>
<img src="/example/contextsens_help_active.gif" alt="example/contextsens_help_active.gif" id="funciconGlobalHelp" title="Help" class="uwrFunctionIcon cuiTableFunctionIcon uwrFunctionIconInTitle">
</a>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr id="ttOverview_heading" class="uwrTableHeading">
<td scope="col" class="uwrFirst uwrTb" style="width:250px;">
<div class="uwrTb">
<!-- skipped -->href="#" class="cuiLink"><img src="/example/0.gif" alt="Collapse all" style="border:0;" class="uwrTreeCollapseAllImage"></a>
</div>
</td>
<td scope="col" class="uwrTb" style="width:40px;">
<div class="uwrTb"> </div>
</td>
<td scope="col" class="uwrTb" style="width:180px;">
<div class="uwrTb uwrCrop">Description</div>
</td>
<td scope="col" class="uwrTb" style="width:40px;">
<div class="uwrTb">CCY</div>
</td>
<td scope="col" class="uwrLast uwrTb" style="width:380px;">
<div class="uwrTb">Blocks and instructions</div>
</td>
</tr>
</tbody>
</table>
<div id="ttOverview_scrollablediv" class="uwrVerticalScrollBox" style="width: 889px; height: 40px;">
<table border="0" summary="" cellpadding="0" cellspacing="0" id="ttOverview" class="uwrTable" style="table-layout:fixed;width:873px;">
<colgroup>
<col width="250">
<col width="40">
<col width="180">
<col width="40">
<col width="363">
</colgroup>
<tbody>
<tr id="ttOverview_row0" class="uwrZebraOdd uwrTableRowHover">
<td id="ttOverview_row0_col0" class="uwrFirst uwrTb" style="width:250px;height:100%;">
<div class="uwrTb" style="height:100%;">[......]</div>
</td>
<td id="ttOverview_row0_col1" class="uwrTb" style="width:40px;height:100%;">
<div class="uwrTb"><button onblur="uwrHideMenu270(this, 'menuttnr', 150);[......]"</button></div>
</td>
<td id="ttOverview_row0_col2" class="uwrTb" style="width:180px;height:100%;">
<div class="uwrCrop uwrTdEllipsis uwrTb"> </div>
</td>
<td id="ttOverview_row0_col3" class="uwrTb" style="width:40px;height:100%;">
<div class="uwrTb"> </div>
</td>
<td id="ttOverview_row0_col4" class="uwrLast uwrTb" style="width:363px;height:100%;">
<div class="uwrTdEllipsis uwrTb"> </div>
</td>
</tr>
<tr id="ttOverview_row1" class="uwrZebraOdd uwrTableRowHover uwrTableLastContentRow">
<td id="ttOverview_row1_col0" class="uwrFirst uwrTb" style="width:250px;height:100%;">
<div class="uwrTb" style="height:100%;">[............]</div>
</td>
<td id="ttOverview_row1_col1" class="uwrTb" style="width:40px;height:100%;">
<div class="uwrTb"><button onblur="uwrHideMenu270(this, 'menuttnp', 150);[......]"</button></div>
</td>
<td id="ttOverview_row1_col2" class="uwrTb" style="width:180px;height:100%;">
<div class="uwrCrop uwrTdEllipsis uwrTb"> </div>
</td>
<td id="ttOverview_row1_col3" class="uwrTb" style="width:40px;height:100%;">
<div class="uwrTb"> </div>
</td>
<td id="ttOverview_row1_col4" class="uwrLast uwrTb" style="width:363px;height:100%;">
<div class="uwrTdEllipsis uwrTb">
<a href="javascript:expandNode("ttnp")" id="lttnp" class="cuiApplLink">Instructions</a> <!------- I want to access this element, and click on link "Instructions" -->
</div>
</td>
</tr>
</tbody>
<input name="actionType" id="actionType" type="hidden" value="">
<span id="sessionBeans">[...]</span>
</table>
<!-- [...] various input name fields -->
</div>
</div>
</div>
<!-- [...] various input name fields -->
</form>
<!-- [...] multiple script-tags -->
</body>
</html>
</iframe>
The C# snippet used looks as follows:
try {
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(20)); // default: 100 seconds
w.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Id("mainframe")));
} catch (Exception ex) {
MessageBox.Show("MSG040: >" + ex.Message + "<", "", MessageBoxButtons.OK);
meldung = "Left after MSG040";
return;
}
try {
driver.SwitchTo().Frame("mainframe");
} catch (Exception ex) {
MessageBox.Show("MSG042: >" + ex.Message + "<", "", MessageBoxButtons.OK);
meldung = "Left after MSG042";
return;
}
try {
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(20)); // default: 100 seconds
w.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Id("WzTtDiV")));
} catch (Exception ex) {
MessageBox.Show("MSG044: >" + ex.Message + "<", "", MessageBoxButtons.OK);
meldung = "Left after MSG044";
return;
}
I can find the iframe "mainframe" just fine, see 1st line in HTML. Then I try to find (using Selenium.Waiter's ElementExists() method, which in essence calls the webdriver's FindElement() method) the element "WzTtDiV" as the first element after the "#document" entry, or the actually required element "lttnp", please see end of HTML snippet.
All hints and tricks found in various sources (ChatGPT, selenium.dev site, Stackoverflow, SauceLabs) tell me, that once I "switched" the current element to the iframe "mainframe" I should be able to "find" all following elements. However, the Wait always expires after timeout and triggers the last exception (MSG044) in the C# code snippet.
I'm under the vague impression that that "#document" entry is somehow blocking access the elements following it. I'm lost at what I'm doing wrong here. Any ideas what I can try?
Thank you very much for your support & Best regards
Volker
Update Dec 11th, 2025 Volker: Hi JeffC, I tried both of your suggestions to locate the element, however, both run into the wait timeout. Please find the stack traces, the full one for the ID method, and below just the first line of the trace for the XPATH method, as all the rest of the stack is identical.
I checked several times and the ID is constant and not auto-generated and always called "lttnp". All other preceeding lines of your code seem to work, the exception fires on the locating attempt of "lttnp". Is it normal that the selector is listed with a #-sign in the stack? --> "#lttnp"
Thank you for any further ideas!
Stack trace for locating by ID:
************** Exception Text **************
OpenQA.Selenium.WebDriverTimeoutException: Timed out after 10 seconds ---> OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#lttnp"}
(Session info: chrome=142.0.7444.176); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
at OpenQA.Selenium.WebDriver.<ExecuteAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.By.<.ctor>b__6_0(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.WebDriver.FindElement(By by)
at SeleniumExtras.WaitHelpers.ExpectedConditions.<>c__DisplayClass7_0.<ElementIsVisible>b__0(IWebDriver driver)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition, CancellationToken token)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition, CancellationToken token)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
at GPPReader.GPPReaderProcessing.LaunchGPPReader(String url) in C:\Dev\GPP-Reader\GPPReaderProcessing.cs:line 600
at GPPReader.GPPReaderForm.Launch_GPPReader_UI() in C:\Dev\GPP-Reader\GPPReaderForm.cs:line 260
at GPPReader.GPPReaderForm.BtnValidateData_Click(Object sender, EventArgs e) in C:\Dev\GPP-Reader\GPPReaderForm.cs:line 185
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Stack trace (first line only) when locating by XPATH, the rest of the trace is identical:
OpenQA.Selenium.WebDriverTimeoutException: Timed out after 10 seconds ---> OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[text()='Instructions']"}
WzTtDiVevery time you load the page? That looks like it is dynamically generated.