sevzas
sevzas

Reputation: 801

Selenium WebDriver set PhantomJS initial viewportSize using PhantomJSOptions

Using Selenium WebDriver under .net, when PhantomJS starts up, the default viewportSize is 400 px wide by 300 px high. Is it possible to increase the default viewportSize using PhantomJSOptions before it is created?

Here is what I tried and it did not seem to have any effect:

    PhantomJSOptions opts = new PhantomJSOptions();

    opts.AddAdditionalCapability("phantomjs.page.viewportSize", "{ width: 1024, height: 768 }");

Here is an alternative that works after the driver is created:

driver.Manage().Window.Size = new System.Drawing.Size(1024,768);

Upvotes: 1

Views: 620

Answers (1)

MikeJRamsey56
MikeJRamsey56

Reputation: 2829

Set the window size using WebDriver.

driver.set_window_size(1024,68)

If you really want to, perhaps this:

var phantomJSDriverService = PhantomJSDriverService.CreateDefaultService(phantomJsDir);
phantomJSDriverService.phantomjs.page.viewportSize = "{ width: 1024, height: 768 }";
var driver = new PhantomJSDriver(phantomJSDriverService);

Upvotes: 2

Related Questions