tests/testthat/test-takes_screenshots_tests.R

context("takes_screenshots_tests")
init <- initFun()
remDr <- init$remDr
rdBrowser <- init$rdBrowser
loadPage <- init$loadPage
on.exit(remDr$close())

test_that("testShouldWriteScreenshotToFile", {
  tmpF <- tempfile()
  result <- remDr$navigate(loadPage("simpleTest"))
  remDr$screenshot(file = tmpF)
  expect_true(file.exists(tmpF))
})

test_that("test_get_screenshot_as_png", {
  if (!.Platform$OS.type == "unix") {
    skip("unix file command used to determine file type")
  }
  tmpF <- tempfile()
  result <- remDr$navigate(loadPage("simpleTest"))
  remDr$screenshot(file = tmpF)
  fileInfo <- system(paste("file --mime-type", tmpF), intern = TRUE)
  expect_true(grepl("image/png", fileInfo))
})

Try the RSelenium package in your browser

Any scripts or data that you put into this service are public.

RSelenium documentation built on Sept. 2, 2022, 9:05 a.m.