Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

moonrise-1.1.7-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file moonrise-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: moonrise-1.1.7-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

Hashes for moonrise-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 99906694117a01f2b310649b2c3f07522b999b8f0545848b636c7d1e74d7c1a5
MD5 3dc9c09e15d360e40390187ebd4523d2
BLAKE2b-256 ed9e80222cb5846d7d4609129f01349f0233bbae6a0e66911a935c1ad1388e66

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page