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.

Details

  • 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.

Note

AppTester depends on the prior installation of a headless web browser, PhantomJS, which you can install with installDependencies.

Super class

shinytest::ShinyDriver -> AppTester

Methods

Public methods

Inherited methods

Method get_ui()

Usage

AppTester$get_ui()


Method get_ui_text()

Usage

AppTester$get_ui_text(squish = TRUE)


Method expect_ui_text()

Usage

AppTester$expect_ui_text(text, squish = TRUE)


Method get_locals()

Usage

AppTester$get_locals()


Method get_globals()

Usage

AppTester$get_globals()


Method get_title()

Usage

AppTester$get_title()


Method expect_title()

Usage

AppTester$expect_title(text)


Method get_problems_info()

Usage

AppTester$get_problems_info()


Method expect_problems_info()

Usage

AppTester$expect_problems_info(text)


Method get_results()

Usage

AppTester$get_results()


Method expect_results()

Usage

AppTester$expect_results(val)


Method stop()

Usage

AppTester$stop(clean = TRUE)


Method clean_output()

Usage

AppTester$clean_output()


Method set_inputs()

Usage

AppTester$set_inputs(...)


Method click()

Usage

AppTester$click(buttons)


Method click_next()

Usage

AppTester$click_next()


Method clone()

The objects of this class are cloneable with this method.

Usage

AppTester$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.