These examples are intended to show the capabilities of some of the steps and value sources included with the Muse Test Framework.
If you have Muse installed, you can run all the examples like this:
muse run suite-all
It will take several seconds for the project to load, then the tests will execute. If you have firefox installed, it will open
twice, to run examples 6 and 7. Example 8 will fail until you build the custom step (see below).
The descriptions here are intended only as a high-level overview. To best understand the examples, open each example with the MuseIDE and step through it to see how it works.
For example:
muse edit ex1-GetAndSetVariable-Verify-Equals.json
Demonstrates how to set a variable and verify a variable is equal to another value.
Demonstrates conditional logic flow: Sets a variable. Then, if the variable is less than a larger number, log a message to the event log.
Implements a loop using a while step with a variable comparison. The end result is sending a message to the event log 3 times.
Shows how to call a macro. The macro increments a variable set by the caller and the result is checked after the macro is complete. Open add5Macro.json file to see how the macro is implemented.
Demonstrates how to call a function with parameters and then check the return value. It also demonstrates variable scoping. Variable counter is set by the caller, but is not visible in the function. Variable var1 is set in the function, but is not visible to the caller. Open variableScopingFunction.json to see how the function is implemented.
This test opens a browser, visits the Github site, enters a loop to search for the Muse project, then on the 3rd try, follows the first project link and then continues to the project wiki.
Demonstrates how element locators may be defined in one place and referenced from many places to avoid duplication. The click step references a locator defined in github-homepage.json.
This test calls a custom step defined in the project. It passes 3 parameters to it, which the custom step writes to the event log. The custom step is implemented in Java - Look for ExampleCustomStep.java under the src folder. To run this test successfully, you must first build the custom step, which requires Java JDK 8 and Gradle on your path. If you have those, run gradle build in the examples folder.
This test calls a custom step defined in the project. It passes 2 parameters to it (abc and xyz). The custom step is implemented in Javascript (example-js-step.js). The test sets two local variables (string1="value1" and int1=17) and passes in two parameters (abc="aaa" and xyz=true). The custom step fails if the the "xyz" paramter evaluates to false or if the string1 variable is not "value1". If then appends "+" and the value of the abc parameter to the string1 value and sets string1 to this new value. It also multiples the int1 variable by 2. After returning, the test then verifies the changes to variables string1 and int1.
This test expects a parameter: the text of a link to click. The test has a default value for this parameter (for use during test development - it is
used when running the test in MuseIDE). The "ex10-suite" test suite contains three values for this parameter, and therefore runs the test 3 times.
Run the suite with:
muse run ex10-suite
This test demonstrates the use of project-level variables. It expects two parameters (browser and browser-provider). Unlike the previous example, they are not defined in the default variables for the test (Parameters tab). Instead, they are defined as project-level varaiables (see project-vars.json). The variables are expected to provide a browser configuration (#"firefox" --> firefox.json) and browser provider (#"local-provider --> local-provider.json) that is used to open the browser.
Demonstrates executing JavaScript in the browser using the Run Javascript step.