Frames and IFrames

Frames from same domain

Sahi automatically traverses across frames and iframes when it tries to identify any element. If there are 2 textboxes with name "user" on the page, one in the main page and the other in an iframe, Sahi will automatically identify the textboxes as _textbox("user") and _textbox("user[1]").

In most cases the tester does not need to know or bother about frames and iframes.

Frames from different domains

When a child frame is from a domain different from the top frame domain, Sahi needs to know which frame or iframe it has to communicate to.

When a child frame or iframe is from a different domain, say, Sahi will prefix the statements with _domain("").

While locating elements in a page, all iframes/frames from a particular domain will be treated as a continuous unit and indexes will span across these frames.

Frame1 Domain:
_textbox("user") without any domain prefix
Frame2 Domain:
used with prefix
Frame3 Domain:
used with prefix
Frame4 Domain:
_textbox("user") used with _domain(""). prefix
Frame1 Domain:
_textbox("user[1]") without any domain prefix
To work with frames from different domains, either use the _domain prefix or use _selectDomain API as mentioned Multiple Domains section.

Subdomains with document.domain

When frames are from the same domain but from different sub domains, the webpage may enable javascript interaction between the frames by setting the document.domain attribute to a common parent domain via javascript.

For example, if Frame1 is from and Frame2 is from, they cannot access each other via javascript. To enable interaction, the page authors can set document.domain='' in their javascript code.

When Sahi navigates to such pages, the Controller may not work on some frames. To check whether frames have set the document.domain, do one of the following:
  1. open the Controller Evaluate Expression box, type document.domain and click "Test-->". You may see something like this: or

    Check the domain in the URL: If it is bigger like then you know that document.domain has been set.
  2. Do a "view source" on the page and search for document.domain. You may see something like:
    document.domain = ""
To make Sahi work with such pages:
  1. Open sahi/userdata/config/domainfix.txt
  2. Add
  3. Save, restart Sahi, clear browser cache and check. The Controller should now work correctly.