ropensci / RSelenium

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

remDr$log("browser") does not show console.log() messages #249

Open gorkang opened 3 years ago

gorkang commented 3 years ago

remDr$log("browser") shows console.warn() and console.error() messages, but does NOT show console.log() messages.

The expected behavior is that console.log() outputs would also be shown.

Please find a reproducible example below:


system('docker stop $(docker ps -q)')
system("docker run -d --shm-size=2g -p 4445:4444 -p 5901:5900 selenium/standalone-chrome-debug")

library(RSelenium)

remDr <- remoteDriver(port=4445L, browserName = "chrome") ##4445 for mac. windows can use 4444
remDr$open(silent = TRUE)
remDr$navigate("https://google.com")

# Gets warnings and errors as expected

remDr$executeScript("console.warn('This is a warning message')")
#> list()
remDr$log("browser")
#> [[1]]
#> [[1]]$level
#> [1] "WARNING"
#> 
#> [[1]]$message
#> [1] "console-api 2:32 \"This is a warning message\""
#> 
#> [[1]]$source
#> [1] "console-api"
#> 
#> [[1]]$timestamp
#> [1] 1.623427e+12

remDr$executeScript("console.error('This is an error message')")
#> list()
remDr$log("browser")
#> [[1]]
#> [[1]]$level
#> [1] "SEVERE"
#> 
#> [[1]]$message
#> [1] "console-api 2:32 \"This is an error message\""
#> 
#> [[1]]$source
#> [1] "console-api"
#> 
#> [[1]]$timestamp
#> [1] 1.623427e+12

# Does NOT get console.log :(

remDr$executeScript("console.log('This is a log message')")
#> list()
remDr$log("browser")
#> list()

Created on 2021-06-11 by the reprex package (v2.0.0)