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.

Bringing a browser window to the foreground

lausserlausser Members
edited November -1 in Sahi - Open Source
Hi,
i wonder if it is possible to bring a window to the foreground when a testscript detected an error. What i'm doing currently is to get the last reached url and the browser string for reporting purposes.
_set($stopURL, window.document.location.href);
   _set($nagiosAgent, navigator.userAgent);
I tried the following to make a browser appear on top, but it didn't work.
_set($dummy, window.focus());
This one didn't work either:
_set($winfocus, window);
   _focus($winfocus);
or
   $winfocus.focus()
It looks like although i can assign window.document.location.href to a javascript variable, i can't do this with the windows object.
Maybe anybody has an idea how it can be achieved?

Gerhard

p.s. what i'm planning is to bring a browser to the foreground and then call with _execute an external program which takes a screenshot.

Comments

  • narayannarayan Administrators
    Try using:
    _call(window.focus());
    
  • lausserlausser Members
    edited April 2009
    Oh, shame on me. I should have seen _call in the documentation.
    Unfortunately is doesn't work. There is just one small difference. When Internet Explorer ist used for the test it still runs in the background, but the symbol in the windows taskbar is highlighted.

    update: it works when i manually playback a script, but not when called via TestRunner.
  • I always started the testrunner in a second window, so this was the foreground window and the browsers appeared in the background. When i configured scheduled tasks, the browsers sometimes ran in the background, sometimes in the foreground.
    Finally i found out: when the cmd-window where sahi.bat was started is in the foreground (it even doesn't need to have the focus, just has to be on top of all other open windows), then also the browser windows will be.

    Gerhard
Sign In or Register to comment.