ashbythorpe / selenider

Concise, Lazy and Reliable Wrapper for 'chromote' and 'selenium'
https://ashbythorpe.github.io/selenider/
Other
32 stars 2 forks source link

Find current URL #3

Closed LukasWallrich closed 11 months ago

LukasWallrich commented 1 year ago

When selenider gets redirected (using chromote), I currently struggle to figure out where it is.

I noticed that session objects have a current_url property - but it remains empty in my case (even though the navigation succeeded, as shown by the screenshot). Is that a bug? Or can I find it anywhere else?

hi <- get_session()
open_url("https://doi.org/10.31234/osf.io/3m5y9", session = hi)
hi$current_url
# NULL
LukasWallrich commented 1 year ago

I now dug deeper into chromote and realised that they don't expose the URL as easily as rSelenium would. I suggested that they might want to change that - https://github.com/rstudio/chromote/issues/128 - but at the moment, it seems possible to get the URL by running get_session()$driver$Runtime$evaluate("window.location.href")$result$value - so maybe that could be used to populate current_url?

ashbythorpe commented 1 year ago

I actually made this function as a helper for one of my tests, but never exported it! It should be exported in the dev version now.

ashbythorpe commented 11 months ago

This change is now released in selenider 0.2.0