rchromote

How to obtain the current URL in R chromote?


I'm experimenting with the chromote package as a replacement for RSelenium. I see how to navigate to a particular URL, but I can't spot the command to use to obtain the current URL. In RSelenium it was getCurrentUrl(); in webdriver it was getUrl().

Is there an equivalent in chromote?

Here's what I've got:

library(chromote)
session <- ChromoteSession$new()
session$Page$navigate("https://stackoverflow.com")

# some clicks etc on the page

# Now where did I end up?


Solution

  • Not sure about a chromote method, though we can evaluate window.location.href:

    library(chromote)
    session <- ChromoteSession$new()
    {
      session$Page$navigate("https://stackoverflow.com")
      session$Page$loadEventFired()
    } 
    #> $timestamp
    #> [1] 1683944
    session$Runtime$evaluate("window.location.href")$result$value
    #> [1] "https://stackoverflow.com/"
    

    Created on 2024-01-30 with reprex v2.0.2