| AppTester | R Documentation |
This is an R6 class for running automated evaluations of psychTestR tests
using the shinytest framework.
When you create an AppTester object,
it spins up a Shiny app and a headless web browser,
which you can then interact with by calling the methods of the
AppTester object.
app <- AppTester$new(dir):
creates a new AppTester object. The argument
dir should be a directory containing a file app.R,
with app.R containing your psychTestR test.
app$stop() - stops the daemon and deletes the output directory.
Call this once you're finished with the AppTester object.
app$click(buttons) - clicks all the buttons with IDs
listed in the character vector buttons.
app$click_next() - clicks the "Next" button.
app$get_ui() - returns the HTML of the current UI of the psychTestR test.
app$get_ui_text() - extracts displayed text from app$get_ui()
using some heuristics. If squish = TRUE, extra whitespace
is removed.
app$expect_ui_text(text, squish = TRUE) - throws an error
if the output of app$get_ui_text(squish = squish)
is not equal to the argument text.
app$get_locals() - returns the current local variables.
app$get_globals() - returns the current global variables.
app$get_title() - returns the current title.
app$expect_title(text) - throws an error
if the output of app$get_title()
is not equal to the argument text.
app$get_problems_info() - returns the "problems info"
text displayed at the bottom of the page.
app$expect_problems_info(text) - throws an error
if the output of app$get_problems_info()
is not equal to the argument text.
app$get_results() - returns the current results for the current participant.
app$expect_results(val) - throws an error
if the output of as.list(app$get_results())
is not equal to val.
app$clean_output() - deletes the output directory.
app$set_inputs(formA = "Text A", formB = "Text B") -
passes (for example) the string "Text A" to the UI
input with ID "formA" and the string "Text B"
to the UI input with ID "formB".
... - AppTester objects inherit from ShinyDriver
objects, and have access to all of their methods.
shinytest::ShinyDriver -> AppTester
shinytest::ShinyDriver$checkUniqueWidgetNames()shinytest::ShinyDriver$enableDebugLogMessages()shinytest::ShinyDriver$executeScript()shinytest::ShinyDriver$executeScriptAsync()shinytest::ShinyDriver$expectUpdate()shinytest::ShinyDriver$finalize()shinytest::ShinyDriver$findElement()shinytest::ShinyDriver$findElements()shinytest::ShinyDriver$findWidget()shinytest::ShinyDriver$getAllValues()shinytest::ShinyDriver$getAppDir()shinytest::ShinyDriver$getAppFilename()shinytest::ShinyDriver$getDebugLog()shinytest::ShinyDriver$getEventLog()shinytest::ShinyDriver$getRelativePathToApp()shinytest::ShinyDriver$getSnapshotDir()shinytest::ShinyDriver$getSource()shinytest::ShinyDriver$getTestsDir()shinytest::ShinyDriver$getTitle()shinytest::ShinyDriver$getUrl()shinytest::ShinyDriver$getValue()shinytest::ShinyDriver$getWindowSize()shinytest::ShinyDriver$goBack()shinytest::ShinyDriver$initialize()shinytest::ShinyDriver$isRmd()shinytest::ShinyDriver$listWidgets()shinytest::ShinyDriver$logEvent()shinytest::ShinyDriver$refresh()shinytest::ShinyDriver$sendKeys()shinytest::ShinyDriver$setInputs()shinytest::ShinyDriver$setValue()shinytest::ShinyDriver$setWindowSize()shinytest::ShinyDriver$snapshot()shinytest::ShinyDriver$snapshotCompare()shinytest::ShinyDriver$snapshotDownload()shinytest::ShinyDriver$snapshotInit()shinytest::ShinyDriver$takeScreenshot()shinytest::ShinyDriver$uploadFile()shinytest::ShinyDriver$waitFor()shinytest::ShinyDriver$waitForShiny()shinytest::ShinyDriver$waitForValue()get_ui()AppTester$get_ui()
get_ui_text()AppTester$get_ui_text(squish = TRUE)
str_squish()AppTester$str_squish(x)
expect_ui_text()AppTester$expect_ui_text(text, squish = TRUE)
get_locals()AppTester$get_locals()
get_globals()AppTester$get_globals()
get_title()AppTester$get_title()
expect_title()AppTester$expect_title(text)
get_problems_info()AppTester$get_problems_info()
expect_problems_info()AppTester$expect_problems_info(text)
get_results()AppTester$get_results()
expect_results()AppTester$expect_results(val)
stop()AppTester$stop(clean = TRUE)
clean_output()AppTester$clean_output()
set_inputs()AppTester$set_inputs(...)
click()AppTester$click(buttons)
click_next()AppTester$click_next()
clone()The objects of this class are cloneable with this method.
AppTester$clone(deep = FALSE)
deepWhether to make a deep clone.
AppTester depends on the prior installation of a headless web browser, PhantomJS,
which you can install with installDependencies.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.