-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only one ChromoteSession
allowed.
#204
Comments
Thanks for opening this @chlebowa. I'm realizing now that this is likely a variant of (or at least related to) a similar issue I solved in rstudio/webshot2#72, but I now have more context. In short, the change is part of the shifting Chrome DevTools Protocol after changes to the headless mode. The error seen above is thrown from Lines 67 to 72 in e3f3bf6
and it appeared with v134 of Chrome, specifically the Chrome binary and not library(chromote) # pak::pak("rstudio/chromote")
with_chrome_version(133, {
b <- ChromoteSession$new()
c <- ChromoteSession$new()
})
with_chrome_version(134, {
b <- ChromoteSession$new()
c <- ChromoteSession$new()
})
#> Error in callback(...): code: -32602
#> message: Target position can only be set for new windows
with_chrome_version(134, binary = "chrome-headless-shell", {
b <- ChromoteSession$new()
c <- ChromoteSession$new()
}) The
In particular, either we need to set library(chromote) # pak::pak("rstudio/chromote")
show_browser_size <- function(b) {
name <- deparse(substitute(b))
windowId <- b$Browser$getWindowForTarget(b$get_target_id())$windowId
bounds <- b$Browser$getWindowBounds(windowId)$bounds
message(sprintf("`%s` has window dimensions: %s x %s", name, bounds$width, bounds$height))
}
with_chrome_version(133, {
b <- ChromoteSession$new()
show_browser_size(b)
c <- ChromoteSession$new(width = 450, height = 900)
show_browser_size(b)
show_browser_size(c)
})
#> `b` has window dimensions: 1200 x 1371
#> `b` has window dimensions: 1200 x 1371
#> `c` has window dimensions: 1200 x 1371
with_chrome_version(134, binary = "chrome-headless-shell", {
b <- ChromoteSession$new()
show_browser_size(b)
c <- ChromoteSession$new(width = 450, height = 900)
show_browser_size(b)
show_browser_size(c)
})
#> `b` has window dimensions: 992 x 1323
#> `b` has window dimensions: 992 x 1323
#> `c` has window dimensions: 450 x 900 This explains the change in behavior that happened in webshot2. Here are a few options:
|
@chlebowa As a quick way around this problem, you can use the dev version of chromote which has new support for managing Chrome installations. You can either use an older version of Chrome or any version of pak::pak("rstudio/chromote")
# Somewhere in your test setup
chromote::local_chrome_version("latest-stable", binary = "chrome-headless-shell")
# ... the rest of your app testing code ... |
Many thanks for the quick reaction @gadenbuie! |
No problem! And yeah, our convention is to use |
Oh and just to be clear, this change in behavior isn't driven by chromote; it's from changes in Chrome. |
Thank you very muach @gadenbuie ! I had the same issue and were able to solve it with the code above. |
Yes, I suspected as much and it was clear in your answer. I decided to bring it to you because I assumed other people using Again, thank you 👍 |
Worked like a charm 🌟 |
I am running a set of
shinytest2
-based tests in which multipleAppDriver
objects are instantiated and later stopped withAppDirver$stop()
.Within the last month these tests started failing and I was able to track the failure down to this:
This happens with
as well as with
and with
chromote v0.3.1
.The text was updated successfully, but these errors were encountered: