executeScript from RSelenium gives error with args

2019-07-11 21:52发布

问题:

I try to reproduce an example code from here

Here is the code:

library("RSelenium")
#start RSelenium server
rD <- rsDriver(verbose = FALSE)
remDr <- rD$client
remDr$open()
remDr$navigate("http://www.google.com/ncr")
script <- "return document.getElementById('hplogo').hidden;"
remDr$executeScript(script, args = list())

and for the last line I receive this error:

Selenium message:unknown error: 'args' must be a list
  (Session info: chrome=60.0.3112.113)
  (Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 6.3.9600 x86_64)

Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     Further Details: run errorDetails method

I can't understand what happens with this error because remDr$navigate works and remDr$executeScript. What is the difference with executeScript and gives this error?

回答1:

This may be a bug in RSelenium as such.

I assume few things that you are on latest version of RSelneium, Chrome and Chromedriver.

Use

remDr$executeScript(script, args = list("dummy"))