Leehbi
Leehbi

Reputation: 779

Setting the viewport size with Rselenium and PhantomJS

I'm using RSelenium and PhantomJS to pull data from a site.

I'm trying to change the useragent and viewport size. I've managed to adjust the useragent but I can't seem to adjust the viewport size.

library(RSelenium)
pJS <- phantom()

eCap <- list(phantomjs.page.settings.userAgent 
             = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0",
             phantomjs.page.viewportsize = "width:1280, height:1024")

remDr <- remoteDriver(browserName = "phantomjs", extraCapabilities = eCap)

remDr$open()
remDr$navigate("http://www.whoishostingthis.com/tools/user-agent/")
remDr$findElement("id", "user-agent")$getElementText()[1]

remDr$close()

With the code below you can see the browser window is 400 x 300.

I've checked the PhantomJS docs and verified phantomjs.page.viewportsize is present.

Any ideas how I can adjust the viewportsize?

Upvotes: 2

Views: 461

Answers (1)

Rentrop
Rentrop

Reputation: 21507

Do you mean something like this:

remDr$setWindowSize(1280L, 1024L)

Upvotes: 5

Related Questions