ropensci / RSelenium

An R client for Selenium Remote WebDriver
https://docs.ropensci.org/RSelenium
341 stars 81 forks source link

RSelenium is not working on the shiny server #269

Open rezasz969 opened 1 year ago

rezasz969 commented 1 year ago

I have an Rscript that uses RSelenium to web scraping. I included this script as a function in my shinyApp. When I run it from my machine (locally) everything works as expected. The trouble occurs when it is published on the shiny server. When I call the application, it shows the message "Dissconected from the sever".

My shinyApp code:

library(shiny)
library(RSelenium)

ui <- fluiPage(
    actionButton('go', 'Scrape')
    )

server <- function(input, output, session){
    observeEvent(input$go, {
        NEW_PATH = paste(Sys.getenv("PATH"), "/usr/lib/jvm/jdk-17/bin/", sep = ":"
        Sys.setenv(PATH)

    rs_driver <- rsDriver(browser = 'chrome',
               chromever = '91.0.4472.101',
               port = 4587L,
               verbose = T,
               check = F)

    obj <- rs_driver$client

    obj$navigate("http://10.18.33.9:7007/ui/")
    Sys.sleep(1)
    })
}

shinyApp(ui, server)

How can I get this to work on the shiny server? Please help! Thank you so much