Test suite creation toolset with additional quality of life upgrades for using the selenium test framework.
Project description
Moonrise
Introduction
Moonrise is a test suite creation toolset with additional quality of life upgrades for using the selenium test framework.
Notable features:
- Test Suite and Test Case organization
- Browser session generation with selenium
- Web element lookup methods with built-in dynamic waits for elements to become available
- Test report generation
Dependencies
Moonrise's current dependencies are:
These are all automatically installed with pip install moonrise
.
NOTE: Recording tests does require one additional piece of software, the lightweight ffmpeg
Installation
Recommend using pypi to install moonrise, pip install moonrise
. You may also retrieve the latest version from github.
Usage
Moonrise is designed for ultimate ease of use while still giving access to the power of the selenium framework. By simply extending the Moonrise class, any Python class becomes a test suite, capable of executing automated test cases and generating test reports.
from moonrise import Moonrise
class ExampleSuite(Moonrise):
@Moonrise.test
def example_test(self):
self.log_to_report("this is a test")
Example Test Suites
Below are two example test suites created to be used with Moonrise. Copy this example code into a python module and then consult the CLI Commands.
from moonrise import Moonrise
### Classes represent test suites ###
class ExampleSuite(Moonrise):
### Default methods for test and suite setup and teardown are provided ###
def suite_setup(self):
self.log_to_report("this is the beginning of the test suite.")
def suite_teardown(self):
self.log_to_report("this is the end of the test suite.")
def test_setup(self):
self.log_to_report("this is the beginning of the test case.")
def test_teardown(self):
self.log_to_report("this is the end of the test case.")
### Tag test cases with @Moonrise.test decorator ###
@Moonrise.test
def example_test(self):
### Use log_to_report() for detailed reporting ###
self.log_to_report("this is a test")
@Moonrise.test
def test_failure(self):
self.log_to_report("this test should fail")
assert 1 == 2, "this failure is intentional"
@Moonrise.test
def test_success(self):
self.log_to_report("this test should pass")
assert 1 == 1
class SeleniumExamples(Moonrise):
### Set the default time to search for web elements ###
Moonrise.default_timeout = 10
def test_setup(self):
### Settings the persist argument to True allows for persistent browser sessions that will remain open and available for reuse with the self.use_current_browser() method ###
self.open_browser("chrome", persist=True)
### moon_driver is the webdriver created with open_browser and can be directly controlled from the test case.
self.moon_driver.maximize_window()
def test_teardown(self):
self.cleanup_browser()
@Moonrise.test
def retrieve_hello_world(self):
self.navigate_to_page("the-internet.herokuapp.com/dynamic_loading/2")
self.click_element("#start button")
self.log_to_report(self.get_text("#finish"))
@Moonrise.test
def fail_to_retrieve_hello_world_in_time(self):
self.navigate_to_page("the-internet.herokuapp.com/dynamic_loading/2")
self.click_element("#start button")
### Waiting for elements to be present can be set on individual keywords ###
self.log_to_report(self.get_text("#finish", timeout=2))
CLI Commands
The easiest way to use Moonrise is through the command line. The CLI offers a broad range of filtering options:
- Use
moonrise (a folder containing python modules)
to execute all Moonrise tests and suites within that folder. - Use
moonrise (a python file)
to target a specific file that may contain Moonrise tests and suites. - Use
test:(test name)
to target specific tests. This keyword may be used more than once in a command and can apply to similarly named tests across multiple suites and python files. - Use
suite:(suite name)
to target specific test suites. This keyword may be used more than once in a command and can apply to similarly named suites across mulitple python files.
With the above example, run only the ExampleSuite
by typing moonrise (path to file or containing folder) suite:ExampleSuite
.
Next, target the failing test by adding test:test_failure
to the command.
To include the SeleniumExamples
test suite in the run, remove the filters entirely and execute moonrise (path to file or containing folder)
.
After each test run, reports and screenshots (upon test failure) are generated at the location from where the tests are run.
Why the Name "Moonrise"?
Since selenium is named after the element Selenium, which is named after Selene, the ancient Greek goddess of the Moon, it only seemed fitting to have a name that incorporated a lunar theme!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file moonrise-1.1.6.tar.gz
.
File metadata
- Download URL: moonrise-1.1.6.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8732cc50667e0c80b2b358064fd67407529e9847c011a3b382c86a44a516f47a |
|
MD5 | a3309b12daa66dc8972c412e36ca9a0d |
|
BLAKE2b-256 | 3fafaf2124ec51555a9ed57effe8a9217f8689a307e83b15901eb9814e3caf31 |
File details
Details for the file moonrise-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: moonrise-1.1.6-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0d335926ef2f44d40cacdf9c59fea5f6425df6bc0bb466f676aab7f2730fab9 |
|
MD5 | 233a0da734b56d5642513c03551c25dc |
|
BLAKE2b-256 | c8cad42ce2b340670ffd4d4f70a057634715c2b9df24ceec2b58838a04e4ec8e |