RSelenium: server signals port is already in use

后端 未结 5 799
北恋
北恋 2020-12-14 08:42

I\'m using the following code in RSelenium to open a browser. After I close the browser, or even close the handler by running remDr$close(), the port is still in use. I have

5条回答
  •  时光说笑
    2020-12-14 09:03

    The process is composed of two parts a server (the Selenium Server) and a client (the browser you initiate). The close method of the remoteDriver class closes the client (the browser). The server also needs to be stopped when you are finished.

    To stop the server when you are finished:

    library(RSelenium)
    rD <- rsDriver(verbose = FALSE,port=4444L)
    remDr <- rD$client
    remDr$close()
    

    Now either explicitly stop the server:

    rD$server$stop()
    

    or if the rD object is removed the server will be stopped upon garbage collection:

    library(RSelenium)
    rD <- rsDriver(verbose = FALSE,port=4444L)
    remDr <- rD$client
    remDr$close()
    rm(rD)
    gc()
    

提交回复
热议问题