I’m encountering a problem where my headless Chrome browser isn’t maximizing correctly when I run my test scripts on a Jenkins machine, despite functioning properly on my local system. Initially, it also had issues locally, but after applying the following code, it began to work there:
Before do |scenario|
DataMagic.load_for_scenario(scenario)
@driver = Watir::Browser.new :chrome, headless: true
width = @driver.execute_script('return screen.width;')
height = @driver.execute_script('return screen.height;')
@driver.driver.manage.window.resize_to(width, height)
@driver.driver.manage.window.move_to(0, 0)
end
While this solved the local issue, it continues to fail on Jenkins. Can anyone help me resolve this? Thank you!
hey emma, jenkins might be running in a different environment than your local machine. Check if jenkins has the required dependencies for headless chrome. Also, try setting specific screen sizes instead of using screen width and height, sometimes helps debugging. Make sure jenkins server supports headless.
It’s often advantageous to consider any difference between your local machine setup and the Jenkins environment. One critical aspect could be the Jenkins machine’s display buffer settings or its lack of a display server entirely if it’s truly headless. Ensure that Xvfb (X virtual framebuffer) is set up on Jenkins, as it can create a virtual display buffer. This acts as a display server to simulate a graphical interface and might resolve the maximizing issue by mimicking a full desktop environment, giving your test scripts the display context they need.
hey emma, me think also try to set explicit window size params directly in wair::browser options, maybe jenkins not reading screen.width/height properly. worth a shot, never know what weird quirk could hiding in there!
gl!