ropensci / RSelenium

An R client for Selenium Remote WebDriver
https://docs.ropensci.org/RSelenium
343 stars 81 forks source link

Documentation about passing arguments (user-agent for example) to Firefox #183

Closed reyman closed 6 years ago

reyman commented 6 years ago

Operating System

Ubuntu

Selenium Server version (selenium-server-standalone-3.0.1.jar etc.)

Docker selenium/standalone-firefox:3.14.0-arsenic

Browser version (firefox 50.1.0, chrome 54.0.2840.100 (64-bit) etc.)

Firefox 61.0

Other driver version (chromedriver 2.27, geckodriver v0.11.1, iedriver x64_3.0.0, PhantomJS 2.1.1 etc.)

I search documentation to change the "user-agent" string using Firefox and RSelenium. I see nothing about that.

I try this, without success

eCaps <- list(`mox:firefoxOptions` = list(general.useragent.override="bla"))
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, extraCapabilities = eCaps )
remDr$open()
remDr$executeScript("return navigator.userAgent;", list(""))

Do you have a working example on that ?

juyeongkim commented 6 years ago

@reyman, try makeFirefoxProfile():

fprof <- RSelenium::makeFirefoxProfile(list(general.useragent.override = "bla"))

remDr <- RSelenium::remoteDriver(
  remoteServerAddr = "localhost",
  port = 4445L,
  extraCapabilities = eCaps
)
remDr$open()

remDr$executeScript("return navigator.userAgent;", list(""))
zonghongtzh commented 5 years ago

Can the same be done for Chrome?