Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago

Microsoft Edge - setting Browser Size Script not working like in other Browsers

def Set_Browser_Size(iWidth):
  Delay(200)
  iHeight=800
  NameMapping.Sys.browser.BrowserWindow.Restore()
  page = NameMapping.Sys.browser.CoyotePage
  wnd = BrowserWindowByPageGet(NameMapping.Sys.browser.CoyotePage)

  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):
    wnd.Maximize()
    Log.Warning(aqString.Format("Viewport size was maximized 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

I am using this version (found on the smartbear site - not sure where it was exactly).

It works for all browsers except for Edge. The problem is the small border of the Browsers resolution 1913x800 should show the desktop view, but on a 1920x12xx only goes into desktop view if maximized - and setting the view to width 1913 will not result in the page being width 1913, so you have the add the border ... which works fine on chrome, firefox, iexplore in all versions 32/64 bit but not on edge ... when i set it to 1913 it says "no border" setting it to 1913 ... but there is one

2 Replies