This repository demonstrates how to automate browser interactions for CHARMM-GUI. The examples provided here test the basic functionality of the CHARMM-GUI module Multicomponent Assembler (MCA), but with minimal work, it should be possible to automate any system creation through MCA.
- Python 3
- Selenium (if using Chrome)
- geckodriver (if using Firefox)
- Splinter
- PyAML
First create a configuration file that points to your CGUI project's /data/www/
directory. E.g.:
BASE_URL: http://localhost:8888/
WWW_DIR: /Users/nathan/multicomp/www
This file should be named config.yml
and be located in the same directory as run_tests.py
. The BASE_URL
shown above is for alpha tests. For beta tests, BASE_URL
should be http://beta.charmm-gui.org/
, and for production tests, the entry can be omitted. If you are using the beta server, you must also include a USER
and PASS
entry.
To run the testing program, execute:
$ ./run_tests.py [opts]
From the main project directory. Use the -h
option to see a list of possible options.
The test_cases/basic.yml
file demonstrates some test cases for MCA. Each test should be written as a YAML array entry, with possible keys described below:
label
(required): The name for this test that will appear in the output log file.base
(required): Directory containing files to upload to C-GUIcomponents
(required): an associative array describing each uploaded component, e.g., to upload files named1ubq.crd
and1ubq.psf
representing a solvated component that should have 3 copies:
1ubq:
type: solvated
count: 3
steps
: an array of actions to perform at each step (described later)final_wait_text
(required): text that should appear only on the final step pagesolvent_test
: an array of solvent variations, e.g.,water+ions
(use both water and ions),water
(don't use ions), orNone
(no water and no ions). If absent, only thewater+ions
variety is tested.
Each step in steps
should be an associative array with the following keys:
wait_text
(required): text appearing on the page that indicates completion of the previous stepelems
(optional): an array of{element_id: value}
pairs. This will change the value of the form element with IDelement_id
so that it holds thevalue
, instead of its default value. This action is performed with Splinter's fill method.presteps
(optional): an array of steps to perform before filling the values ofelems
. Will be evaluated withCGUIBrowserProcess.eval()
, which defaults to Python's built-ineval()
.poststeps
(optional): an array of steps to perform after filling the values ofelems
. Same format aspresteps
.
Next, extend the CGUIBrowserProcess
class. See the example in MCABrowserProcess.py
. The most important requirement is that you define an init_system()
method that determines how to get through the first step of your module.
Finally, write tests for your project. See the examples in test_cases/basic.yml
.
MCABrowserProcess
is for running tests on Multicomponent Assembler. To run tests on a different CHARMM-GUI module, you must extend the CGUIBrowserProcess
class in a similar manner. This base class manages a Splinter browser instance in a thread-safe manner.
For more information about Python's parallelism, see the multiprocessing documentation.