Replace phantomjs with chrome as headless browser#82
Replace phantomjs with chrome as headless browser#82Faye-yufan wants to merge 4 commits intomasterfrom
Conversation
|
thanks, this is a great first step toward modernizing the test framework! |
|
I opted to use the Chromedriver in the However, there are still a few tests that fail in my local environment (macOS, arm64, Chrome version: 111.0.5563.110):
Failure (test-renderer1-axis-angle-rotate.R:48:3): axis.text.x=element_text(angle=90) means transform="rotate(-90)" ──
title_box$top >= tick_box$bottom is not TRUE
`actual`: FALSE
`expected`: TRUE
Backtrace:
▆
1. └─animint2 (local) expect_rotate_anchor(info, "-90", "end") at test-renderer1-axis-angle-rotate.R:48:2
2. └─testthat::expect_true(title_box$top >= tick_box$bottom) at test-renderer1-axis-angle-rotate.R:33:2
── Failure (test-renderer1-axis-angle-rotate.R:56:3): axis.text.x=element_text(angle=70) means transform="rotate(-70)" ──
title_box$top >= tick_box$bottom is not TRUEInterestingly, these tests pass perfectly in Firefox. The transform="translate(x, y)" values are different between Chrome and Firefox. This could be attributed to the differences in rendering engines and the implementation of CSS styles across browsers.
── Error (test-tt-inter.R:3:1): (code run outside of `test_that()`) ────────────
<packageNotFoundError/error/condition>
Error in `find.package(package, lib.loc, verbose = verbose)`: there is no package called ‘animint’I suspect this is due to the old |
|
Also some concerns:
|
|
You wrote "The following error occurs in test-shiny.R" but are you sure that you were running test-shiny.R? The output says |
|
tests_init('chrome') gives an error on windows, any idea how to fix? > tests_init("chrome")
HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon
version REG_SZ 111.0.5563.65
Error: C:\Users\th798\AppData\Local/binman/binman_chromedriver app directory not found.
> Serving the directory C:\Users\th798\R\animint2\tests\testthat at http://127.0.0.1:4848
> traceback()
6: stop(assertError(attr(res, "msg")))
5: assert_that(app_dir_exists(appdir))
4: app_dir(appname)
3: binman::list_versions("chromedriver") at helper-HTML.R#71
2: rev(binman::list_versions("chromedriver")[[1]]) at helper-HTML.R#71
1: tests_init("chrome")
> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 4.2.2 (2022-10-31 ucrt)
os Windows 10 x64 (build 19042)
system x86_64, mingw32
ui RTerm
language (EN)
collate English_United States.utf8
ctype English_United States.utf8
tz America/Phoenix
date 2023-03-22
pandoc 2.11.3.2 @ C:\\PROGRA~1\\Pandoc\\pandoc.exe
─ Packages ───────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
animint2 * 2023.3.10 2023-03-22 [1] local
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.0)
binman 0.1.3 2022-09-01 [1] CRAN (R 4.2.1)
bitops 1.0-7 2021-04-24 [1] CRAN (R 4.2.0)
brio 1.1.3 2021-11-30 [1] CRAN (R 4.2.0)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.0)
callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.2)
caTools 1.18.2 2021-03-28 [1] CRAN (R 4.2.1)
cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.2)
colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.2)
crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.2)
data.table 1.14.9 2023-03-21 [1] local
devtools 2.4.5 2022-10-11 [1] CRAN (R 4.2.2)
digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0)
fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.2)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.2)
htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2)
htmlwidgets 1.6.1 2023-01-07 [1] CRAN (R 4.2.2)
httpuv 1.6.9 2023-02-14 [1] CRAN (R 4.2.2)
httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.2)
knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2)
later 1.3.0 2021-08-18 [1] CRAN (R 4.2.0)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.0)
mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0)
pkgbuild 1.4.0 2022-11-27 [1] CRAN (R 4.2.2)
pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.2.2)
plyr 1.8.8 2022-11-11 [1] CRAN (R 4.2.2)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0)
processx 3.8.0 2022-10-26 [1] CRAN (R 4.2.2)
profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.1)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.0)
ps 1.7.2 2022-10-26 [1] CRAN (R 4.2.2)
purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.2.0)
Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.2)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.0)
RJSONIO 1.3-1.8 2023-01-31 [1] CRAN (R 4.2.2)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.2)
RSelenium * 1.7.9 2022-09-02 [1] CRAN (R 4.2.2)
scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.2)
semver 0.2.0 2017-01-06 [1] CRAN (R 4.2.1)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
shiny 1.7.4 2022-12-15 [1] CRAN (R 4.2.2)
stringi 1.7.12 2023-01-11 [1] CRAN (R 4.2.2)
stringr 1.5.0 2022-12-02 [1] CRAN (R 4.2.2)
testthat * 3.1.6 2022-12-09 [1] CRAN (R 4.2.2)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.1)
usethis 2.1.6 2022-05-25 [1] CRAN (R 4.2.2)
vctrs 0.5.2 2023-01-23 [1] CRAN (R 4.2.2)
wdman 0.2.6 2022-09-01 [1] CRAN (R 4.2.3)
xfun 0.37 2023-01-31 [1] CRAN (R 4.2.2)
XML * 3.99-0.13 2022-12-04 [1] CRAN (R 4.2.2)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.1)
[1] C:/Users/th798/AppData/Local/R/win-library/4.2
[2] C:/Program Files/R/R-4.2.2/library
──────────────────────────────────────────────────────────────────────────────
|
Sorry for the mix-up, the below is the error from test-shiny.R: ── Error (test-shiny.R:14:1): (code run outside of `test_that()`) ──────────────
<packageNotFoundError/error/condition>
Error in `loadNamespace(x)`: there is no package called ‘animint’
Backtrace:
▆
1. └─base::loadNamespace(x) at test-shiny.R:14:0
2. └─base::withRestarts(stop(cond), retry_loadNamespace = function() NULL)
3. └─base (local) withOneRestart(expr, restarts[[1L]])
4. └─base (local) doWithOneRestart(return(expr), restart)And thanks for the feedback for the Windows environment, I'll look into that and work on a fix. |
|
I'm still unable to get it to work due to incompatibility between the Chrome version and the Chrome Driver version on my machine. |
|
what do you think would be the way forward here? it seems like it should be possible to get a current chrome + compatible chromeDriver... |
|
I have utilized WebDriver managers There are two most straightforward ways I can think of now:
I think the real snag here here is the ChromeDriver has to work with the Chrome browser, even if in the headless mode, and the version of ChromeDriver typically lag behind the browser's. |
|
what do they do in other projects? we are not the only ones using chromeDriver on github.... |
|
I've looked into it and it seems that many packages like |
|
thanks for looking at other R packages like webdriver and webshot, and finding that Chromote is now recommended over chromedriver. That is useful. |
|
I see, I'll dive deeper into that. But here's the problem: in our Also, ChromeDriver used to be released over here: https://chromedriver.storage.googleapis.com/index.html. But they've changed the urls to https://googlechromelabs.github.io/chrome-for-testing/#stable. I'm thinking that this might be why the |
|
this PR is no longer relevant because #126 implemented chromote for testing. |
This pull request replaces the previous use of PhantomJS as the headless testing browser with Chrome, which was done to resolve the issue of getting Dynamic HTML via JavaScript DOM nodes. Previously, the remote driver
getPageSource()function returned the original skeletal HTML when attempting to retrieve XML.Here is an example of the output returned by the PhantomJS remote driver when requesting a page:
After switching to chrome and using the headless mode with
wdmanextra arguments, most of the tests that check for html node/property values were fixed. However, there are still a few failed tests remaining.