"那时候一切都好多了"......
因为firefox 49(?)你不能使用rselenium包不再直截了当.我已经搜索了整个互联网,找到了一个简单的如何手动设置rselenium但没有发现任何相关和最新的.
有人可以提供我和其他所有其他人没有线索的简单操作手册吗?喜欢:
所以我可以运行如下代码
require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4444L,
browserName = "firefox")
remDr$open()
Run Code Online (Sandbox Code Playgroud)
下载最新版本RSelenium >= 1.7.1.运行以下命令:
library(RSelenium)
rD <- rsDriver() # runs a chrome browser, wait for necessary files to download
remDr <- rD$client
# no need for remDr$open() browser should already be open
Run Code Online (Sandbox Code Playgroud)
如果你想使用firefox浏览器rsDriver(browser = "firefox").
这在http://rpubs.com/johndharrison/RSelenium-Basics附录中有详细说明.但是,推荐的运行RSelenium的方法是通过Docker容器.有关使用RSelenium的Docker的说明,请访问http://rpubs.com/johndharrison/RSelenium-Docker
问题:
如果由于管理员权限或其他变量(如防病毒软件)而出现问题,则可以手动运行Selenium服务器.最简单的方法是通过wdman包:
selCommand<-
wdman::selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"),
retcommand = TRUE)
> cat(selCommand)
C:\PROGRA~3\Oracle\Java\javapath\java.exe -Dwebdriver.chrome.verboseLogging=true -Dwebdriver.chrome.driver="C:\Users\john\AppData\Local\binman\binman_chromedriver\win32\2.27/chromedriver.exe" -Dwebdriver.gecko.driver="C:\Users\john\AppData\Local\binman\binman_geckodriver\win64\0.14.0/geckodriver.exe" -Dphantomjs.binary.path="C:\Users\john\AppData\Local\binman\binman_phantomjs\windows\2.1.1/phantomjs-2.1.1-windows/bin/phantomjs.exe" -jar "C:\Users\john\AppData\Local\binman\binman_seleniumserver\generic\3.0.1/selenium-server-standalone-3.0.1.jar" -port 4567
Run Code Online (Sandbox Code Playgroud)
使用启用wdman了该retcommand选项的其中一个函数将返回已运行的命令行调用.
现在,您可以在终端中运行cat(selCommand)的输出
C:\Users\john>C:\PROGRA~3\Oracle\Java\javapath\java.exe -Dwebdriver.chrome.verboseLogging=true -Dwebdriver.chrome.driver="C:\Users\john\AppData\Local\binman\binman_chromedriver\win32\2.27/chromedriver.exe" -Dwebdriver.gecko.driver="C:\Users\john\AppData\Local\binman\binman_geckodriver\win64\0.14.0/geckodriver.exe" -Dphantomjs.binary.path="C:\Users\john\AppData\Local\binman\binman_phantomjs\windows\2.1.1/phantomjs-2.1.1-windows/bin/phantomjs.exe" -jar "C:\Users\john\AppData\Local\binman\binman_seleniumserver\generic\3.0.1/selenium-server-standalone-3.0.1.jar" -port 4567
12:15:29.206 INFO - Selenium build info: version: '3.0.1', revision: '1969d75'
12:15:29.206 INFO - Launching a standalone Selenium Server
2017-02-08 12:15:29.223:INFO::main: Logging initialized @146ms
12:15:29.265 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:15:29.265 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
12:15:29.265 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:15:29.266 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
12:15:29.271 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
2017-02-08 12:15:29.302:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-02-08 12:15:29.317:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@c4c815{/,null,AVAILABLE}
2017-02-08 12:15:29.332:INFO:osjs.ServerConnector:main: Started ServerConnector@4af044{HTTP/1.1}{0.0.0.0:4567}
2017-02-08 12:15:29.333:INFO:osjs.Server:main: Started @257ms
12:15:29.334 INFO - Selenium Server is up and running
Run Code Online (Sandbox Code Playgroud)
现在尝试运行浏览器
remDr <- remoteDriver(port = 4567L, browserName = "chrome")
remDr$open()
Run Code Online (Sandbox Code Playgroud)
如果您无法手动运行Selenium Server,则需要将问题(包括相关日志文件)解决到Selenium项目或相应的驱动程序项目(chromedriver/geckodriver/ghostdirver等).
运行docker pull selenium/standalone-chrome-debug在终端(或CMD用于视窗)
4445在端口上键入。单击“加号”符号,键入5901将在 Ports 上创建的其他输入。它应该如下图所示。之后,单击运行。

在 Rs 控制台中,转到:
install.packages("RSelenium")
library(RSelenium)
remDr <- remoteDriver(
remoteServerAdd = "localhost",
port = 4445L,
browser = "chrome"
)
remDr$open()
Run Code Online (Sandbox Code Playgroud)
每次您希望 RSelenium 工作时,您都需要像上面的第 3 步和第 5 步一样运行 Docker 容器。
这些步骤还允许您使用 VNC 来观察发生的情况并进行调试。如果您需要了解一些相关信息,请访问https://www.realvnc.com/pt/connect/download/viewer/更多详细信息超出了本主题的范围。
好吧,我认为这可以让您达到现在可以按照 RSelenium 基本用法小插图的这些说明进行操作的地步:https ://cran.r-project.org/web/packages/RSelenium/vignettes/basics.html
您还应该阅读与暴露端口相关的安全性以及如何处理它。来自 R Consortium 的这些视频可能会帮助您从这里开始:https : //www.youtube.com/watch?v=OxbvFiYxEzI和https://www.youtube.com/watch?v=JcIeWiljQG4
我希望它可以帮助你,就像你之前帮助过我一样。