Ask a Question

Resizing Window

Frequent Contributor

Resizing Window



how exactly should I resize the browser window in test complete?


I tried it with BrowserWindow.Position(0,0,width,1000) in a function where I give the width as parameter ... But it sets the window size to idk 1697 or something rather than my 1710 I sent to the function.


Is there a better way to resize the BrowserWindow during runtime?

Frequent Contributor

It works - even tho its kind of complicated, but well, better complicated than not 😛

Here the code in python if someone needs it:

def Set_Browser_Size(page, iHeight, iWidth):
  wnd = BrowserWindowByPageGet(page)
  iBorderWidth = wnd.Width - page.Width
  iBorderHeight = wnd.Height - page.Height

  iWinWidth = iWidth + iBorderWidth
  iWinHeight = iHeight + iBorderHeight

  Log.Message(aqString.Format("Set browser\'s viewport size to %ix%i (window size is %ix%i)", iWidth, iHeight, iWinWidth, iWinHeight),
      aqString.Format("%ix%i\n%ix%i", iWidth, iHeight, iWinWidth, iWinHeight));

  res = (iWinWidth > Sys.Desktop.Width) | (iWinHeight > Sys.Desktop.Height)
  if (res):
    Log.Warning(aqString.Format("Viewport size was not changed as it exceeds current size of the desktop (%ix%i)",
        Sys.Desktop.Width, Sys.Desktop.Height))
    if ((wnd.Width != iWinWidth) | (wnd.Height != iWinHeight)):
      wnd.Position(0, 0, iWinWidth, iWinHeight)
  return res
def BrowserWindowByPageGet(Page):
  if (Page.Exists):
    if ("Page" == Page.ObjectType):
      if ('edge' == Page.Parent.ObjectIdentifier):
        wnd = Page.Parent.BrowserWindow(0)
        title = Page.contentDocument.title
        wnd = Page.Parent.FindChild("WndCaption", title + "*")
  return wnd
Regular Contributor

Hi Lagencie


This is what I use and wonderfully for me (javascript) -




Sys.Browser("*").BrowserWindow(0).Position(0, 0, 1400, 1080);

Hope this works for you as well.


Frequent Contributor

This can not work @royd because this solutions sets the Browser size, so the content is set to whatever is left.


You need to check the different borders, as in chrome it is around 30px, in firefox around 25px, in edge only 10px so if you use .Position it only makes the outer lines of the browser to 1400 width - but I needed the content to be at least 1400px.



My problem right now is with Edge @AlexKaras did you test Edge already with your provided code? For me the wnd.width - page.width says = 0 because the variables seem to be the same on MicrosoftEdge ... Not sure what I should do here, I made it now If Browser Edge => add 9,8px as this is the standard Edge Border size, which is fairly cheap and cheated, but works ... Do you have a better solution for this problem probably?



Well... I did not use Edge intensively for some time (especially, after April Update or how it was called) but I believe that the code worked at least acceptable for me.


I tried to double check and I can confirm that it looks like there is some problem with Edge 42.17134.1.0 (Microsoft EdgeHTML 17.17134) and TestComplete 12.60.5220.7 32-bit (Beta).


I am not sure what are those 9.8px that you mention here and in related thread (, but I found out that in my case:

-- <Edge>.Window(0).Width equals to 1337;

-- <Edge>.page(...).Width equals to 1337 as well;

-- The following code reports 1337 to the log

  page := Sys.Browser('edge').Page('');
  wnd := Sys.Browser('edge').BrowserWindow(0);
  rect := Win32API.TRect;
  Win32API.GetWindowRect(wnd.Id, rect);
  Log.Message(aqString.Format('wnd.Width=%i, page.Width=%i, rect.right-rect.left = %i', wnd.Width, page.Width, rect.right-rect.left));

-- The screenshot taken via Alt-PrnScr for the Edge window and pasted into both Paint and IrfanView is reported as an image of 1339 pixels width.


@HKosova@TanyaYatskovska could you please ask Support guys to look into this? Or this needs to be reported as an issue?




  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
Frequent Contributor

the 9.8 px is what I have found out is the "Border" MicrosoftEdge actually has, so right now my script only makes "if browser = Edge" iBorderWidth += 9.8 this way it creates the content right (but yeah this is a very dirty solution 😛 )

Showing results for 
Search instead for 
Did you mean: