18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to access elements in an iframe
After clicking on a button to select a file, the browser displays an iframe with a _file() element and a button to upload this file.
I can assert that the _iframe() exists but can't seem to access any of the components within it.
I need to assert that the _file() input field exists and fill it with a value.
How do I do this within an iframe?
Here is the main bits of html.
...
<div id="zk_comp_2477!cave" class=" z-window-modal-cnt">
<span id="zk_comp_2478" class="z-label" z.zcls="z-label">Specify a file located in your local system</span>
<iframe id="zk_comp_2479" frameborder="0" src="/webui/zkau/web/8914214/zul/html/fileupload.html.dsp?dtid=gbov&uuid=zk_comp_2477&max=1&native=false&maxsize=-1" style="width:97%;border: 1px solid #aaa;" z.type="zul.widget.Ifr">
<html ...>
...
<body onload="init()">
<form id="form" onsubmit="submitUpload()" method="POST" enctype="multipart/form-data" action="/webui/zkau/upload?dtid=gbov&maxsize=-1&uuid=zk_comp_2477">
<input type="hidden" value="false" name="native">
<div style="overflow-y:auto;overflow-x:hidden;width:100%;height:;">
<table id="upload-list" border="0" width="100%">
<tbody>
<tr>
<td align="right"></td>
<td>
<input id="file" class="file" type="file" name="file">
</td>
</tr>
</tbody>
</table>
</div>
...
</form>
</body>
</html>
</iframe>
</div>
I can assert that the _iframe() exists but can't seem to access any of the components within it.
I need to assert that the _file() input field exists and fill it with a value.
How do I do this within an iframe?
Here is the main bits of html.
...
<div id="zk_comp_2477!cave" class=" z-window-modal-cnt">
<span id="zk_comp_2478" class="z-label" z.zcls="z-label">Specify a file located in your local system</span>
<iframe id="zk_comp_2479" frameborder="0" src="/webui/zkau/web/8914214/zul/html/fileupload.html.dsp?dtid=gbov&uuid=zk_comp_2477&max=1&native=false&maxsize=-1" style="width:97%;border: 1px solid #aaa;" z.type="zul.widget.Ifr">
<html ...>
...
<body onload="init()">
<form id="form" onsubmit="submitUpload()" method="POST" enctype="multipart/form-data" action="/webui/zkau/upload?dtid=gbov&maxsize=-1&uuid=zk_comp_2477">
<input type="hidden" value="false" name="native">
<div style="overflow-y:auto;overflow-x:hidden;width:100%;height:;">
<table id="upload-list" border="0" width="100%">
<tbody>
<tr>
<td align="right"></td>
<td>
<input id="file" class="file" type="file" name="file">
</td>
</tr>
</tbody>
</table>
</div>
...
</form>
</body>
</html>
</iframe>
</div>
This discussion has been closed.
Comments
Check if the two iframes are from different domains like a.maindomain.com and b.maindomain.com.
If they are from different domians then, open sahi/userdata/config/domainfix.txt and add
*.maindomain.com maindomain.com
Save, restart Sahi.
Regards
Sumitra
Can you share the URL for both parent window and the iframe?
Regards
Sumitra
Thanks for your help.
I'm testing ADempiere. The test site and domain for the components is asds2.adempiere.de:8080/webui
Script info follows.
Mike.
Login: GardenAdmin
PW: GardenAdmin
Following login with defaults, the script is:
function open_window($windowName){
_click(_div($windowName));
}
function close_window($windowName){
_click(_link(/./,_near(_span($windowName))));
}
function test_bf3017942_sep_char() {
var $importLocation = "c:\\adempiere\\data\\ ";
open_window("Import File Loader");
_click(_cell("/Select File to Load/")); // Opens the iframe
_setFile(_file("file"), $importLocation + "AccountingUS.csv"); // <-- fails here. _file("file") is not found.
_click(_submit("Upload"));
_setSelected(_select(1), "Accounting - Accounts");
_click(_cell(">"));
_click(_cell(">"));
_assertEqual("Assets", _getValue(_textbox(2)));
_log("BF3017942 test passed", "info");
close_window("Import File Loader");
}
Sorry to waste your time.
Thanks.
Mike.