“那时候一切都好”。
自从firefox 49 (?)您不能再直接使用rselenium包了。我已经搜索了整个互联网寻找一个简单的如何手动设置rselenium,但没有找到任何相关的和最新的。
有人能提供给我和所有那些不知道如何操作的人吗?比如:
这样我就可以运行如下代码
require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4444L,
browserName = "firefox")
remDr$open()发布于 2017-02-26 13:12:41
下载最新版本的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如果您想使用火狐浏览器,请使用rsDriver(browser = "firefox")。
这在http://rpubs.com/johndharrison/RSelenium-Basics附录中有详细说明。然而,运行RSelenium的推荐方法是通过Docker容器。使用RSelenium的码头操作说明可在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使用一个启用了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现在试着运行一个浏览器
remDr <- remoteDriver(port = 4567L, browserName = "chrome")
remDr$open()如果您无法手动运行Selenium Server,那么您将需要解决Selenium项目或适当的驱动程序项目(chromedriver/geckodriver/ghostdirver等)的问题(包括相关的日志文件)。
发布于 2020-12-08 03:17:55
docker pull selenium/standalone-chrome-debug
单击Run

4445。单击“加号”,在将在端口上创建的其他输入上键入5901。它应该看起来像下面的图片。之后,单击Run。

每次您希望RSelenium工作时,您都需要运行Docker容器,就像您在上面的步骤3和5中所做的那样。
这些步骤还允许您使用VNC监视所发生的事情和调试。如果您需要了解更多关于它的知识,请访问https://www.realvnc.com/pt/connect/download/viewer/,更多的细节不在本主题的范围之内。
嗯,我认为这可以带您到一个点,您现在可以按照RSelenium的基本用法说明:https://cran.r-project.org/web/packages/RSelenium/vignettes/basics.html
您还应该了解与公开的端口相关的安全性以及如何处理它。来自R集团的这些视频可能会帮助您从这里:https://www.youtube.com/watch?v=OxbvFiYxEzI和https://www.youtube.com/watch?v=JcIeWiljQG4
我希望它能对你有帮助,就像你在一段时间前会帮助我一样。
https://stackoverflow.com/questions/42468831
复制相似问题