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.

Storing a reference to a popup in a variable

peterfarsinsenpeterfarsinsen Members
edited November -1 in Sahi - Open Source
Hi,

I'm trying to figure out a way to store a reference to a popup, but so far I've not been able to figure out how to do so.

What I would like to do is something along the lines:
function getPopup() {
    return _popup('popupName');
}

var $pop = getPopup();
$pop._doSahiStuff();

In the above case $pop will be undefined even though _popup('popupName'); does find the popup. Calling _popup('popupName')._someSahiMethod(); does work, but that's not really as DRY as I would like it.

Is it possible at all to store a reference to a popup? If so please let me know how ;)

Thanks in advance!

- Peter

Comments

  • narayannarayan Administrators
    Hi Peter,

    You can do something else though. There is an API called _selectWindow(popupId). Have a look at _selectWindow() here: http://sahi.co.in/w/miscellaneous-apis

    Regards,
    Narayan
  • Hi narayan,

    Don't know how I missed that.

    It's not exactly what I was looking for, but it's working very well.

    Thanks for helping out!

    Cheers,

    Peter
  • narayannarayan Administrators
    You missed it because I added the docs after your question ;)

    Cheers,
    Narayan
  • Ha ha. Nice one!

    On that note, are there any plans to restructure the API? I've been working with SAHI for a couple of weeks and I find the sectioning of topics on different pages a bit unintuitive and pretty hard to navigate (especially to search). I think having them all on one page is a better solution now.

    Cheers,

    - Peter
  • narayannarayan Administrators
    Are you suggesting that we should club all the Accessor, Action and Miscellaneous APIs together? That could definitely make API lookups easier.
  • Yes, that's what I'm suggesting. I see why the API is split into three, but I'm often confused by it when looking for something.

    As an example the _log(), _wait() and all of the assertion methods could just as well be placed on the misc. page.

    I really depends on how you use the API, but as a big fan of the browsers built in page search, having it all on one page would make sense ;) Other might not agree.

    - Peter
Sign In or Register to comment.