Skip to content

Generates Selenium IDE test cases from a custom macro language

Notifications You must be signed in to change notification settings

gonzalob/macrolang-to-selenium-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MacroLang to Selenium HTML

MacroLang is a custom XML syntax, closely coupled to Selenium IDE's commands as of now, but adding the possibility of arbitrarily grouping commands under a given name.

Motivation

The testing team at my workplace has had a great increase in speed and quality of their work by recording tests in Selenium IDE, but they've hit an obstacle in maintainability of the generated tests. Plus, they're reluctant to learn a programming language.

Context

Our project's lifecycle seems to be good enough right now. Developers add some feature to the application. The testers record some tests to automatically check its validity. Both commit to the SCM. Developers in Java, testers in Selenium IDE's HTML syntax. Integration servers then translate the HTML tests into Java code using Selenium HTML to Java, compiles and runs it with each commit.

Many of the recorded tests have tasks, groups of commands, that are repeated throughout the test suite. When a feature request means some change to any of these tasks, testers are required to re-record many tests, or use string replacement all over the suite, but this is way too error prone.

Maven Plugin

This tool integrates to a Maven build lifecycle by declaring a mojo execution bound to the generate-test-sources phase.

Implementation

The language has mainly three constructs: test, command and macro. A command is translated to exactly one Selenium IDE command, a macro is a group of commands or other macros, and a test is the actual test to be executed, which can be composed of commands, macros or both.

Test

<test name="test-case-001" title="My Test Case" base="http://localhost"
 encoding="ISO-8859-1">
 <login username="johndoe@mailinator.org" password="s3cr3t" />
</test>

A test is the sequence of commands and macros that are actually converted to Selenium IDE's source HTML syntax. The encoding attribute is optional, and defaults to UTF-8

Commands

<command name="click" target="id=logout" />

Macros

<macro name="login">
 <open-homepage /><!-- another macro -->
 <command name="type" target="id=username" value="$username" />
 <command name="type" target="id=password" value="$password" />
 <command name="click" target="id=submit" />
</macro>

Macros are groups of commands, and can receive arbitrary arguments prefixed with the $ symbol.

Parametrized Macro Calls

<macro name="login-via">
 <parametrized-macro name="login-$socialNetwork" />
</macro>

Parametrized macro calls are calls to macros with parameters in their names.

Project Links

License

This software is licensed under the GPLv3.

About

Generates Selenium IDE test cases from a custom macro language

Resources

Stars

Watchers

Forks

Packages

No packages published