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.