RSelenium UnknownError-java.lang.IllegalStateException与Google Chrome
我正在基于以下脚本运行以下脚本: 根据来自的注释,我修改了我的RSelenium UnknownError-java.lang.IllegalStateException与Google Chrome,java,r,selenium,rselenium,Java,R,Selenium,Rselenium,我正在基于以下脚本运行以下脚本: 根据来自的注释,我修改了我的startServer()命令,如下所示: startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE) 然后,我在控制台中收到以下错误: Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. cl
startServer()
命令,如下所示:
startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE)
然后,我在控制台中收到以下错误:
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: java.lang.IllegalStateException
在弹出的Java提示符中出现以下错误:
14:38:55.098 INFO - Launching a standalone Selenium Server
14:38:55:161 INFO - Java: Oracle Corporation 25.40-b25
14:38:55.161 INFO - OS: Windows 7 6.1 amd64
14:38:55.161 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
14:38:55.209 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:38:55.209 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
14:38:55:289 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4455/wd/hub
14:38:55:289 INFO - Selenium Server is up and running
我不确定缺少Opera驱动程序是一个实际的错误还是一个警告。不管怎样,我想使用Chrome,所以这似乎不重要。我做错了什么?我最终能够通过将来自多个不同来源的信息拼凑在一起,使RSelenium发挥作用。我认为将所有这些信息放在一个位置会很有帮助,因此以下是我让RSelenium在以Chrome为浏览器的Windows 7(64位)上运行的过程:
checkForServer()
。startServer()
,但它经常会被卡住,无法继续执行脚本中的下一行。以下是我创建的批处理文件:
java -jar C:\path\to\selenium-server-standalone.jar -Dwebdriver.chrome.driver=C:\path\to\chromedriver.exe
ChromeDriver可以放在PATH环境变量中,但我决定将ChromeDriver的路径添加到批处理文件中(这实现了相同的目标)library(RSelenium)
shell.exec(paste0("C:\\path\\to\\yourbatchfile.bat"))
Sys.sleep(5)
remDr <- remoteDriver(browserName = "chrome")
remDr$open(silent = TRUE)
remDr$navigate("http://www.google.com")
库(RSelenium)
shell.exec(粘贴0(“C:\\path\\to\\yourbatchfile.bat”))
系统睡眠(5)
remDr值得注意的是,硒对OSX有一些恼人的区别。分别运行yourcommand.command文件和remDr$open()方法时,invisible=T/silent=T参数将不起作用。不可见=T实际上会提醒您它只在Windows上工作。没什么大不了的(如果有人有解决办法,我会很感激)
为了子孙后代的利益,这里有一个小小的变化,OSX使用.command文件而不是.bat替换shell.exec,其内容与上面相同:
yourcommand.command文件内容
java -jar /path/to/selenium-server-standalone.jar -Dwebdriver.chrome.driver=/path/to/chromedriver
R脚本修改
library(RSelenium)
system(paste("open","/path/to/yourcommand.command"))
Sys.sleep(5)
...
你是否有可以从你的路径中的某个地方访问的chromedriver。
java -jar /path/to/selenium-server-standalone.jar -Dwebdriver.chrome.driver=/path/to/chromedriver
library(RSelenium)
system(paste("open","/path/to/yourcommand.command"))
Sys.sleep(5)
...