How do I set the browser screen size? When I take a screen shot after setting up PhantomJS as below its only showing a 400px wide image.
var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
driverService.LoadImages = false;
driverService.ProxyType = "none";
using (var driver = new PhantomJSDriver(driverService))
{
etc....
}
It should be the same as setting window size in any other browsers, feel free to have a look at this example: How to get window size, resize or maximize window using Selenium WebDriver.
Here is the code tested working for me:
var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
driverService.LoadImages = false;
driverService.ProxyType = "none";
using (var driver = new PhantomJSDriver(driverService)) {
driver.Manage().Window.Size = new Size(1920, 1080); // Size is a type in assembly "System.Drawing"
driver.Url = "http://www.stackoverflow.com";
driver.TakeScreenshot().SaveAsFile(@"c:\phantomjs_screenshot.png", ImageFormat.Png);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With