ropensci / RSelenium

An R client for Selenium Remote WebDriver

Home Page:https://docs.ropensci.org/RSelenium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to keep the browser opening?

yuanzhouIR opened this issue · comments

Hi there. I'm using this package on Mac OS. It works fairly well. However, when my code finished running, Chrome automatically closed after a few minutes. I want to keep the browser opening regardless of there are operations running or not. How should I set the code to prevent the browser from closing?

similar issue here:
https://stackoverflow.com/questions/55438913/is-there-a-way-too-prevent-selenium-automatically-terminating-idle-sessions

untested, but something like this should work:

chrome_prefs = 
  list(  
   # chrome prefs
    "profile.default_content_settings.popups" = 0L,
    "download.prompt_for_download" = FALSE
    )

chrome_args = 
  c(
  # chrome command arguments
    '--headless',
    '--window-size=1200,1800',
    '-sessionTimeout 57868143'
    )

eCaps_notimeout = 
  list(chromeOptions = 
         list(
           prefs = chrome_prefs,
           args = chrome_args 
  ))


  remDr <- remoteDriver(
    browserName = "chrome",
    extraCapabilities = eCaps_withhead
  )

similar issue here:
https://stackoverflow.com/questions/55438913/is-there-a-way-too-prevent-selenium-automatically-terminating-idle-sessions

untested, but something like this should work:

chrome_prefs = 
  list(  
   # chrome prefs
    "profile.default_content_settings.popups" = 0L,
    "download.prompt_for_download" = FALSE
    )

chrome_args = 
  c(
  # chrome command arguments
    '--headless',
    '--window-size=1200,1800',
    '-sessionTimeout 57868143'
    )

eCaps_notimeout = 
  list(chromeOptions = 
         list(
           prefs = chrome_prefs,
           args = chrome_args 
  ))


  remDr <- remoteDriver(
    browserName = "chrome",
    extraCapabilities = eCaps_withhead
  )

Thanks for your reply! Increasing the value of sesssionTimeout works for me.