Forum Discussion

Siax's avatar
Siax
Contributor
12 years ago

Maximize browser window

Hi,

I'm hoping to find a solution to make sure the browser is maximised before testing comenses.

I launch the browser using:



Browsers.Item(btIExplorer).Run(Project.Variables.websiteUrl);



I was wondering how I can ensure this is maximised?

I was using:-

Sys.Process("IEXPLORE").BrowserWindow(0).Maximize();

but this is unreliable as it's hard coded and the browser might not be in running  as BrowserWindow(0).



Any assistance is appreciated.

5 Replies

  • This may not be the most efficient way to Maximize all Browser Windows, but it does work.



    function MaximizeBrowserWindows()

    {

        var BrowserWindows=Sys.FindAll("ObjectType", "BrowserWindow", 3).toArray();   

       

        for (var i = 0; i < BrowserWindows.length; i++)

        {

            BrowserWindows.Maximize();

        }

    }
    • hhagay's avatar
      hhagay
      Contributor

      Hello

       

      The code is throwing and error. Any chance you execute it and verify if you experience similar result?

       

      Thank you

       

       

      • royd's avatar
        royd
        Regular Contributor

        I just stumbled onto this post, I know it is very very late. I am pretty new at this myself.

         

        I thought it is still might be useful for someone else. The downside to this is, losing tabs, URL, bookmarks etc.

         

        JScript/Javascript&colon;

        var page = (*) // or specific url
        
        Sys.Browser.page.Keys("[F11]");

         

        or

        var page = (*) // or specific url
        
        Sys.Browser.page.Keys(~ " "); //there is a 'space' between "
        Sys.Browser.page.Keys(x);

         

         

        Hope this comes handy for someone.

         

        Dave

  • gk1970's avatar
    gk1970
    Occasional Contributor
    Just to add what Mike stated. Better to find the BrowserIndex of the browser instance used and use that.

    In VBscript though, some thing like this..


    Set wScriptObj = Sys.OleObject("WScript.Shell") Call wScriptObj.Run("iexplore.exe " & ProjectSuite.Variables.URL)


    wScriptObj = .OleObject("WScript.Shell")  wScriptObj.Run("iexplore.exe " & .Variables.URL)

     


    Set browser=Sys.Browser("iexplore")


    Set page = browser.Page(ProjectSuite.Variables.Page)

    index=browser.BrowserIndex


     


    browser.BrowserWindow(index).Maximize