簡體   English   中英

RSelenium通過碼頭工人

[英]RSelenium through docker

我的操作系統是Windows 8.1,我有R的3.3.3版本。

我已經安裝了RSelenium軟件包,我嘗試使用它運行它:

library("RSelenium")
#start RSelenium server
startServer()
checkForServer()

我收到此錯誤:

Error: checkForServer is now defunct. Users in future can find the function in 
file.path(find.package("RSelenium"), "examples/serverUtils"). The
recommended way to run a selenium server is via Docker. Alternatively
see the RSelenium::rsDriver function.

RSelenium開放的方式有什么變化嗎? 我搜索錯誤,我發現只有這個,但它沒有幫助我。 我能做什么?

另外我嘗試的另一種方法是從這里下載chromedrive'https ://sites.google.com/a/chromium.org/chromedriver/downloads '

並使用此腳本:require(RSelenium)cprof < - getChromeProfile(“C:/Users/Peri/Desktop/chromedriver/chromedriver.exe”,“Profile 1”)

require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost" 
                      , port = 4444
                      , browserName = "chrome", extraCapabilities = cprof
)
remDr$open()

我收到此錯誤:

Error in checkError(res) : 
  Couldnt connect to host on http://localhost:4444/wd/hub.
  Please ensure a Selenium server is running.

我該怎么做才能運行chrome而不是預先默認的瀏覽器Firefox?

您需要使用rsDriver函數。 Selenium版本希望你使用Docker(我也建議使用),但是如果你不熟悉它,你可以這樣做。

rsdriver將管理運行Selenium Server所需的二進制文件。 這提供了圍繞wdman :: selenium函數的包裝器。

以下是啟動Chrome瀏覽器時需要執行的操作:

driver<- rsDriver()
remDr <- driver[["client"]]

然后你可以使用它:

remDr$navigate("http://www.google.de")
remDr$navigate("http://www.spiegel.de")

並阻止它:

remDr$close()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM