driver.manager().getSize() return (768, 548), which is too small

29 views
Skip to first unread message

Reed Xia

unread,
May 15, 2018, 5:17:07 AM5/15/18
to seleniu...@googlegroups.com
Hi there,

My project is Selenium Webdriver + Jenkins, and it is running on Slave node(Ubuntu 14.04) with Xvfb( Xvfb screen is set to 1024x768x24) and Firefox 40.

I add the statement "driver.manager().getSize()" and it returns (768, 548), which is too small.

Is it a normal case?(while the resolution 768 * 548 is correct when Xvfb set to 1024x768x24)

And could someone share how to set a bigger resolution for the browser running?

Thanks,
Reed

Jonathan Herbaut

unread,
May 15, 2018, 5:45:07 AM5/15/18
to Selenium Users
Hi,
It's normal to have a lower size of your browser when you use GetSize. Depending on your browser, the GetSize will return the area of your html render and not the size of your window. The browser has toolbars that eat the height of the page.
But the width is the most of the time the same than the one you requires.
Can you see your firefox running ? You will quickly understand why your GetSize is so low.

To set the size, you just need to write the property remote.Manage().Window.Size where remote is your remoteWebDriver.

Reed Xia

unread,
May 16, 2018, 5:46:31 AM5/16/18
to seleniu...@googlegroups.com
Hi Jonathan,

Thanks for the reply and your suggestion! I can't see Firefox running because our team setup Xvfb to run the Selenium tests in a headless way.

I added  "driver.manage().window().setSize(new Dimension(1024, 768))" and now the problem is resolved.

Thanks,
Reed


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0d04aa3a-2663-4802-84cb-8ab3f6945e9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages