1

I try to automatically run an R script in Windows 8 using task scheduler as petermeissner explains in this thread. Below I pasted (part of) the script. The script does everything until remDr$getPageSourece(). I get a pop-up message saying 'R for Windows front-end has stopped working'. However, if I run the script in R (so not using scheduler) no error occurs. What can be possibly wrong?

pacman::p_load(RSelenium)
appurl <- "https://prod.beeline.com/ucb/Security/NewLogin.aspx?Url=%2fucb"
setwd("../downloaded")

RSelenium::checkForServer()
RSelenium::startServer()

Sys.sleep(5) 

remDr <- RSelenium::remoteDriver(browserName="chrome") #For chrome make sure the file 'chromedriver is under 'downloaded'. Also this file can be found on TFS

remDr$open(silent=T)
remDr$navigate(appurl) 
Sys.sleep(1)
remDr$findElement(using = "css selector","#beelineForm_UserLoginForm_userNameText")$sendKeysToElement(list("username"))
Sys.sleep(1)
remDr$findElement(using = "css selector","#beelineForm_UserLoginForm_passwordText")$sendKeysToElement(list("passwd"))
remDr$findElement("css selector", "#loginButton")$clickElement() 

appurlNew <- "https://prod.beeline.com/ucb/Procurement/Request/ProcurementRequestListScreen.ascx"
Sys.sleep(1)

remDr$navigate(appurlNew)
Sys.sleep(3)

x <- getwd()
write(x, file="workingdir1.txt")

remDr$getPageSource()

EDIT: I tried re-running the script in R and now it also seems to block at remDr$getPageSource(). R says it 'searches for a function definition' until the session aborts.

Community
  • 1
  • 1
user3387899
  • 601
  • 5
  • 18
  • Are you sure you are running the R script in the same version of R when you check vs. what the task scheduler loads? – kristang Feb 24 '16 at 09:31
  • Thanks for the comment. I have only one version of R installed on my PC (R-3.2.2), so I suppose so? – user3387899 Feb 24 '16 at 09:34
  • Worth a shot. Sometimes people rely on the Rscript added to path on install, but forgot to update it when they move to another version of R. I assume you also use the direct link to your Rscript.exe as explained by petermeissner - "C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" or whatever. – kristang Feb 24 '16 at 09:49
  • Yes I use that direct link indeed. I am afraid I do not completely understand you. Should I update my R version? – user3387899 Feb 24 '16 at 10:06
  • No, it was just a thought :) – kristang Feb 24 '16 at 10:31
  • Ok thank you. Please also see my edit in the question. Maybe this looks familiar. – user3387899 Feb 24 '16 at 11:04
  • I'm not familiar with the package you are using so I'm just guessing things I have had issues with in the past when running scheduled tasks. Perhaps try loading `methods`. It might be a dependency for your application, and it is not part of the base packages in Rscript. – kristang Feb 24 '16 at 13:29

0 Answers0