Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain the current URL in R chromote?

Tags:

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?

like image 625
user2554330 Avatar asked Nov 15 '25 23:11

user2554330


1 Answers

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

like image 160
margusl Avatar answered Nov 17 '25 11:11

margusl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!