Forum Discussion

testbogus's avatar
testbogus
Occasional Contributor
3 years ago

web browser size scripting

Hello
When testcomplete was executed in a virtualized environment, the browser size became smaller, and even though the size was small,

scrolling was not possible in some cases.

If the window is forced to shrink in a virtualized environment and scrolling doesn't work, can the script resize it?

When you use a batch program to exit the virtualized environment and run the test, the window size is forced to shrink and the test may fail.

I want to keep the browser window size significantly even after the virtualized environment is closed, but I don't know how to write a script.

I would like to know how to use the scripting feature to increase the size of the window with height and width options.
thank you.

4 Replies

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Marsha_R :

       

      Yes, this code is still a part of my ScriptExtension and works fine for me. Even in CrossBrowserTesting environment.

       

  • testbogus's avatar
    testbogus
    Occasional Contributor

    I've looked closely at the contents of the script, but I'm not sure how to apply the script to the test scenario.
    Can you give an example?

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      Real test in CrossBrowserTesting.com cloud environment:

            try
            {
              aqTestCase.Begin(str);
      
              // Get reference to remote browser (RE: Case #00456278: How to programmatically end test running in CBT?)
              browser = Utils.CreateStubObject();
              Browsers.RemoteItem(server, JSON.stringify(remote)).Run(url);
              browser = Sys.Browser();
              var page = browser.Page(Project.Variables.pvURL);
      
              viewport = BrowserViewportSizeGet(page);
              Log.Message(aqString.Format('Viewport before resize (WxH): %ix%i', viewport.width, viewport.height));
              BrowserViewportSet(page, remote);
              viewport = BrowserViewportSizeGet(page);
              Log.Message(aqString.Format('Viewport after resize (WxH): %ix%i', viewport.width, viewport.height));
              KeywordTests.Login.Run();
              KeywordTests.Logout.Run();
            }
            finally
            {
              // Close remote session
              if (browser.Exists && ('remote' == browser.ObjectIdentifier))
              {
                browser.Close();
                while (browser.Exists)
                  Delay(500);
              }
      
              aqTestCase.End();
            } // try