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)) else: 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) else: title = Page.contentDocument.title wnd = Page.Parent.FindChild("WndCaption", title + "*") return wnd
Sys.Browser("*").BrowserWindow(0).Position(0, 0, 1400, 1080);
Hope this works for you as well.
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 (https://community.smartbear.com/t5/TestComplete-Functional-Web/Microsoft-Edge-setting-Browser-Size-S...), 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('https://support.smartbear.com/readyapi/docs/servicev/configure/dispatch/parameter.html'); 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.
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 )