chromote icon indicating copy to clipboard operation
chromote copied to clipboard

Losing interactivity with chromote controlled browser after 1st page loaded

Open stadbern opened this issue 1 year ago • 12 comments

Hi all , after:

library(chromote)
b <- ChromoteSession$new()
b$view()
b$Page$navigate("https://github.com/rstudio/chromote")

I cannot interact with the open chromebrowser like clicking on signin or typing (need it for login) subsequently after executing:

b$Page$navigate("https://fr.wikipedia.org/wiki/Wikipédia:Accueil_principal")

stays blocked on "https://github.com/rstudio/chromote"

this is with the dev version of chromote chromote : rstudio/chromote@3a870d5

all the rest is the most recent on my set-up Google Chrome : 133.0.6943.142 ChromeDriver : 133.0.6943.141

which version of the chromedriver is recommended for rstudio/chromote@3a870d5 and how to point chromote explicitly to it's location?

devtools::session_info(pkgs = "chromote") :

─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────
setting  value
version  R version 4.4.2 (2024-10-31)
os       macOS Sonoma 14.7.2
system   aarch64, darwin20
ui       RStudio
language (EN)
collate  en_US.UTF-8
ctype    en_US.UTF-8
tz       Mars
date     2025-02-28
rstudio  2024.12.1+563 Kousa Dogwood (desktop)
pandoc   NA
quarto   1.5.45 @ /usr/local/bin/quarto

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────
package     * version    date (UTC) lib source
AsioHeaders   1.22.1-2   2022-12-08 [1] CRAN (R 4.4.1)
chromote    * 0.4.0.9000 2025-02-28 [1] Github (rstudio/chromote@3a870d5)
cli           3.6.4      2025-02-13 [1] CRAN (R 4.4.1)
cpp11         0.5.1      2024-12-04 [1] CRAN (R 4.4.1)
curl          6.2.1      2025-02-19 [1] CRAN (R 4.4.1)
fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.4.1)
jsonlite      1.9.0      2025-02-19 [1] CRAN (R 4.4.1)
later         1.4.1      2024-11-27 [1] CRAN (R 4.4.1)
magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.4.1)
processx      3.8.6      2025-02-21 [1] CRAN (R 4.4.1)
promises      1.3.2      2024-11-28 [1] CRAN (R 4.4.1)
ps            1.9.0      2025-02-18 [1] CRAN (R 4.4.1)
R6            2.6.1      2025-02-15 [1] CRAN (R 4.4.1)
Rcpp          1.0.14     2025-01-12 [1] CRAN (R 4.4.1)
rlang         1.1.5      2025-01-17 [1] CRAN (R 4.4.1)
websocket     1.4.2      2024-07-22 [1] CRAN (R 4.4.1)
withr         3.0.2      2024-10-28 [1] CRAN (R 4.4.1)
zip           2.3.2      2025-02-01 [1] CRAN (R 4.4.1)

[1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library

stadbern avatar Feb 28 '25 11:02 stadbern

I've also seen this too. I don't think it's a chromote problem, I'm pretty certain it's on the Chrome side. Calling b$view() again opens a new window with a display of the current page that will be interactive again. I'm hoping this problem will be fixed in future versions of Chrome.

gadenbuie avatar Feb 28 '25 13:02 gadenbuie

I’ve also come across this issue, and it’s pretty annoying. Calling the view() method again, as suggested by @gadenbuie, doesn’t solve it—it still doesn’t open the page properly.

Positron Version: 2025.03.0 (system setup) build 97
Code - OSS Version: 1.96.0
Commit: 5e22d6f831ad2a23b08e66de8111e693b30afaf1
Date: 2025-02-25T20:39:11.000Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

Chrome version 133.0.6943.142

davidrsch avatar Mar 03 '25 10:03 davidrsch

Hi, found a workaround

point chromote to the chrome browser version that works for you:

For me picked the first and oldest in the list: all_chrome_versions_to_cache = chrome_versions_list(which=c("all")) chrome_versions_add(version = "113.0.5672.0", binary = "chrome")

path = chrome_versions_path() Sys.setenv(CHROMOTE_CHROME = path)

chrome_session = ChromoteSession$new() chrome_session$view() chrome_session$Page$navigate("https://fr.wikipedia.org/wiki/Wikipédia:Accueil_principal") chrome_session$Page$navigate("https://google.com")

all scripts work again.

stadbern avatar Mar 03 '25 17:03 stadbern

point chromote to the chrome browser version that works for you:

Yeah, this is why I'm pretty sure it's a Chrome problem (among a few other reasons).

You can also do this a little bit more easily with the following code:

library(chromote) # dev chromote from rstudio/chromote

# Use a very old Chrome version
local_chrome_version("113.0.5672.0")

chrome_session = ChromoteSession$new()
chrome_session$view()
chrome_session$Page$navigate("[fr.wikipedia.org/wiki/Wikipédia:Accueil_principal](https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal)")
chrome_session$Page$navigate("[google.com](https://google.com/)")

Also you may have better results using a newer version of the chrome-headless-shell binary:

local_chrome_version(binary = "chrome-headless-shell")

# ... ChromoteSession$new() code ...

gadenbuie avatar Mar 03 '25 17:03 gadenbuie

Hello, I tried both solutions, without any succes:

library(chromote)

all_chrome_versions_to_cache = chrome_versions_list(which = c("all"))
chrome_versions_add(version = "113.0.5672.0", binary = "chrome")
#> [1] "C:/Users/david/AppData/Local/R/cache/R/chromote/chrome/113.0.5672.0/chrome-win64/chrome.exe"
path = chrome_versions_path()
Sys.setenv(CHROMOTE_CHROME = path)
chrome_session = ChromoteSession$new()
#> Error in `startup()`:
#> ! Chrome debugging port not open after 10 seconds.
library(chromote)

local_chrome_version("113.0.5672.0")
#> chromote will now use version 113.0.5672.0 of `chrome` for win64.
ChromoteSession$new()
#> Error in `startup()`:
#> ! Chrome debugging port not open after 10 seconds.

Could this failure be OS related?

davidrsch avatar Mar 03 '25 18:03 davidrsch

@davidrsch Yeah, there could be Windows-specific issues with the new experimental chrome versions manager. Could you open a new issue? Can you also try (using local_chrome_version()) a newer version of Chrome, too, like 135? Thanks!

gadenbuie avatar Mar 03 '25 18:03 gadenbuie

Hello @gadenbuie when trying with a newer version of Chrome I no longer recieve error in new method but I do in view

library(chromote)
local_chrome_version("135")
#> chromote will now use version 135.0.7047.0 of `chrome` for win64.
chrome_session = ChromoteSession$new()
chrome_session$view()
#> Error in chromote$url(path): path must be NULL or a string that starts with "/"

davidrsch avatar Mar 03 '25 22:03 davidrsch

Hello @gadenbuie, I was able to test with an older version of Chrome and successfully interact with example pages like Wikipedia and Google. However, when trying to interact with pages where I previously encountered this issue, such as Papa John’s, I’m still unable to interact with the page regardless of the Chrome version. This suggests the issue might be related to something else.

library(chromote)

# Use a very old Chrome version
local_chrome_version("113.0.5672.0")

chrome_session = ChromoteSession$new()
chrome_session$view()
chrome_session$Page$navigate("https://www.papajohns.com.co/nuestros-locales")

It opens properly but I can't interact with the selector

davidrsch avatar Mar 04 '25 15:03 davidrsch

In the hope that it may help others:

On my Windows 11 machine, group policy prevented local_chrome_version("113.0.5672.0") from working. What I did instead was:

  • Download and extract https://storage.googleapis.com/chrome-for-testing-public/113.0.5672.0/win64/chrome-win64.zip
  • Run the extracted chrome.exe once and click "run anyway" when required
  • Set the enviroment variable CHROMOTE_CHROME=full path to the extracted chrome.exe
  • Restart RStudio

Now my old scripts using chromote (through library(selenider)) work again, letting me log in manually to a web page before automating further operation.

jonovik avatar Mar 19 '25 09:03 jonovik

On my Windows 11 machine, group policy prevented local_chrome_version("113.0.5672.0") from working. What I did instead was:

You can also use chromote_versions_path("113.0.5672.0") to get the path to the chrome.exe file. I'm pretty sure that if you run that file (like you did with the extracted chrome.exe) and click "run anyway" when required, you'll end up with a working version of chrome that will then work with local_chrome_version().

gadenbuie avatar Mar 19 '25 13:03 gadenbuie

Are the functions like local_chrome_version() and chromote_versions_path() exposed in the Github devversion of chromote?

I am running chromote * 0.4.0 2025-01-25 [1] CRAN (R 4.2.0) and all of the suggested functions are not recognized by the library...

ucb avatar May 07 '25 07:05 ucb

Are the functions like local_chrome_version() and chromote_versions_path() exposed in the Github devversion of chromote?

They were added in chromote 0.5.0 which is now on CRAN. (Actually, we've also published a follow-up v0.5.1 version to CRAN since.)

gadenbuie avatar May 07 '25 12:05 gadenbuie