18 January 2026:


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.

Iframe in Sahi

WebTesterWebTester Members
edited November -1 in Sahi - Open Source
Hi Folks,
I am new to sahi and I need some help understanding this issue and how to automate my web

site.I am having issues trying to access the iframe pages that are called by the hosted

site.The certificates are installed correctly for https (uses 2 certificates one for hosted

site and other for iframed links).The issue I have here is that the sahi controller is not

able to identify the elements that are in iframe page.When I do ALT+CTL+dbl clk on the

hosted site the controller opens with the hosted site with url --

_s_/spr/controller7.htm.When I mouseover the elements on the iframed pages ,sahi is not

showing the elements properties in the controller.

iframes page urls are under abc.xyz.com.
eg:iframedir.abc.xyz.com/iframedir/file.aspx.
Iam using 06-2010 sahi build and firefox browser
Any idea what is happening here ,and how can this be automated in sahi.Sahi docs mentioned

it does not support iframes that are in different domains,my webpages are in same domain

,but still not able to identify the elements in sahi.
I appreciate any help in this regard..

Comments

  • narayannarayan Administrators
    Hi WebTester,

    The pages are from different sub-domains. One needs to set document.domain to a common base domain to make this work.

    Here is what you need to do:

    Open sahi/htdocs/spr/domainfix.js

    You should see:
    var d = window.document.domain;
    if (d){
        var ix = d.lastIndexOf(".");
        ix = d.lastIndexOf(".", ix-1);
        if (ix!=-1){
            //document.domain = d.substring(ix+1);
        }
    }
    

    Uncomment
    //document.domain = d.substring(ix+1);
    so that your code now looks like
    var d = window.document.domain;
    if (d){
        var ix = d.lastIndexOf(".");
        ix = d.lastIndexOf(".", ix-1);
        if (ix!=-1){
            document.domain = d.substring(ix+1);
        }
    }
    


    Restart Sahi, clear browser cache, and try again.

    Regards,
    Narayan
  • This fixed my problem.
    Thanks a lot.
  • Hi Narayana ,
    I see a diffirent issue now after uncommenting the line in domainfix.js.The sahi controller is able to identify the elements when I mouse over on iframed elements .However,when I run the script that clicks on a menu element hosted on hostedsite.xyz.com (opens iframed page below the menu) I get the following error in sahi .
    Sahi Code: _click(_cell("menuItem"));
    Error:
    uncaught exception: [Exception... "Illegal document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: "hostedsite.xyz.com Line: 442"] (:).

    Application site:
    hosted pages: hostedsite.xyz.com
    iframed pages : iframesite.hostedsite.xyz.com

    Our developers mentioned they have set the document.domain to xyz.com to allow communication between the hosted site pages and iframed pages .Also,the uncommented code is not being executed .
    on the other note:
    When I ran the code in sahi controller that is in domainfix.js

    var d = window.document.domain;
    if (d){
    var ix = d.lastIndexOf(".");
    _alert(ix); -- outputs 2
    ix = d.lastIndexOf(".", ix-1);
    _alert(ix); -- outputs -1 and not entering if condition
    if (ix!=-1){
    document.domain = d.substring(ix+1);
    }
    }

    I appreciate any help to resolve this issue ?
Sign In or Register to comment.