1

I have my E2E tests firing in a build pipeline using Team City and the corresponding build agent. The build agent is installed as a service but is running under an account that allows it access to network resources across the development network. Therefore, it can interact with the desktop fine and launch Chrome/FireFox etc.

My question is that the resolution that the tests appear to be running in is kinda small. Like 1024 or less. I'm gauging this from screenshots generated from test failures. Is there anyway to change this? It causes a lot of time outs and errors since some elements don't appear in the window but appear fine on desktops since the entire page is rendered without the need to scroll. Otherwise,I have to do the JS to scroll the window up and down to get to my elements.

rg702
  • 92
  • 1
  • 5

2 Answers2

1

You can maximise window:

driver.Manage().Window.Maximize();

or set size using JS:

((IJavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");
kotoj
  • 769
  • 1
  • 6
  • 25
  • Thanks but already do that. It's like the actual user session itself is smaller than usual. – rg702 Jun 24 '16 at 14:09
  • @rg702 - Did you get the resolution of this issue. we are also facing similar kind of issue in team city server. – tyaga001 Jan 17 '19 at 09:18
  • @tyaga001 look at my another answer. I guess it might be not Selenium problem, but the configuration of server where tests are run. With provided command you will be able to verify it. – kotoj Jan 22 '19 at 13:05
  • @rg702 Thanks, we figured it out, It's a server screen resolution problem only. & I tried with headless chrome but with headless chrome I am getting No such element exception & when i see screenshot, it's a blank page. any help here, as we can't change the server screen resolution so we thought to give a try with headless chrome. – tyaga001 Jan 23 '19 at 09:26
  • I have no experience with headlesses. Try to find similiar question or ask your own, but as a separate topic, not here I think. Good luck! – kotoj Jan 23 '19 at 14:16
  • any resolution to this? – agleno Jul 27 '21 at 13:56
0

You can use PowerShell command to retrieve actual screen resolution:

Get-WmiObject -Class Win32_DesktopMonitor | Select-Object ScreenWidth,ScreenHeight

Answer taken from Here

If resolution will be less than expected, it means it is not Selenium problem, but only the host machine, and need to be investigated further.

Community
  • 1
  • 1
kotoj
  • 769
  • 1
  • 6
  • 25