To keep our user manual up-to-date, I would like to automate the update of screenshots from one of the tools we are using.
Following the instructions on the chromote github page (and after making Chromium the default web browser in my Ubuntu 18.04 LTS), I am able to access a test website, but I am unable to retrieve the screenshots.
Step 1:
interactive login (with redirection)
library(chromote)
b <- ChromoteSession$new()
b$view()
b$Page$navigate("https://dev79379.service-now.com/nav_to.do?uri=%2Fcatalog_home.do%3Fsysparm_view%3Dcatalog_default")
Which is redirected to the login page in the devtools viewer. After login I am properly redirected to the requested page.
Step 2: Save the cookies
#catch and save the cookies
cookies <- b$Network$getCookies()
str(cookies)
saveRDS(cookies, "cookies.rds")
Finally, I restart R and Chromium, read the cookies and load the page.
library(chromote)
b <- ChromoteSession$new()
b$view()
cookies <- readRDS("cookies.rds")
b$Network$setCookies(cookies = cookies$cookies)
# Navigate to the app that requires a login
b$Page$navigate("https://dev79379.service-now.com/nav_to.do?uri=%2Fcatalog_home.do%3Fsysparm_view%3Dcatalog_default")
b$screenshot()
Unfortunately, this displays only an empty page without the catalog items and refers to the container
ServiceNow (the banner and the left menu)
resulting in the below error in the R console in Rstudio
> b$screenshot()
[1] "An error occurred: Error in onRejected(...): code: -32000\n message: Could not find node with given id\n"
Warning message:
In onRejected(reason) :
An error occurred: Error in onRejected(...): code: -32000
message: Could not find node with given id
Running the same process on
https://dev79379.service-now.com/home does work the first run, but triggers the same error when you try to save another (or the same) page.
How can this be solved?