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.

How to switch between child and parent windows?

dkdk Members
edited November -1 in Sahi - Open Source
Hi
I have a list of reports in parent window (uses HTTP) . Each link opens to a SSRS report (HTTPS ) window.
I could record each window separately. But if I combine child and parent scripts together, controller could not identify child window elements.

Parent url: http://mydomain/reportlist
child : https://mydomain/report
Controller recognizes child window as _popup("windowname")

Expecting my script to work like this


_click(_link($reportName));
_popup("windowname")._assertExist(_span($reportName));
.....child window scripts.......
.....back to parent window....

How can I switch between parent and child windows when parent uses HTTP and child uses HTTPS ?

Thanks

Comments

  • narayannarayan Administrators
    Hi dk,

    http parent window opening https child window works fine on IE8 and Firefox 3.6

    Which browser are you using?

    When you specify a _popup("xxx") it targets the xxx child window.
    If you do not add any _popup prefix, then it points to the parent window.

    Regards,
    Narayan
  • dkdk Members
    I found the issue occurred when I combined the parent and child scripts together. Child popup's script got executed fast even though there was enough _wait(time) provided, giving a log of popup script failure.
    So I changed SAHI properties to accommodate more delay in steps.
    Now its working fine.

    But only thing I have to do is to open the controller on child window to identify its elements. Again, close and open the controller on parent window to identify parent elements.
    This is noticed only in HTTPS child window.
    I had another scenario of parent and child using same protocol, then never had to open and close controller on each window.

    Thanks a lot to Narayan for looking into this.
  • Hi Narayan,

    How about If both window's are http based?

    parent: http://mydomain/reportlist/subreportlist00
    child: http://mydomain/reportlist/subreportlist11

    Thanks,
    Roshi
  • Hi Roshi,

    If the Parent window and the Child window's URL are http then Sahi will prefix the child window with _popup and will run the scripts.

    You can find the sample script in <sahi-home>/userdata/scripts/demo/popup_title_name_mix.sah

    Here is a simple example:
    _navigateTo("http://sahi.co.in/demo/");
    _click(_link("Window Open Test"));
    _popup("popWin")._click(_link("Prompt Page"));
    _popup("popWin")._setValue(_textbox("t1"), "hi");
    _expectPrompt("Some prompt?", "")
    _popup("popWin")._click(_button("Click For Prompt"));
    _popup("popWin")._click(_link("Back"));
    

    Let me know if you face any problem.

    Regards
    Sumitra
Sign In or Register to comment.