Test Generation Web

MyITest4U allows you to generate tests automatically.

The Test Generators will overwrite existing tests. There is no warning and no undo.

Test names of generated tests will start with "_". Underscore is not allowed in test names. Test names of generated tests need to be changed before they can be saved. This avoids an accidental overwrite of changed generated tests and their parameter files. This behavior can be changed using the GUI or by overriding the method setGeneratedTestName(String testName) of the class MyGenConfig.

Form Test Generator

This test generator will create a test for each form of your application. The generator uses the information stored in the MyITest4U data base in the following way:

  1. A search for all form tags is done.
  2. A search for all GUI elements belonging to a form tag is done.
    Thereby it is assumed, that GUI elements belonging to a form have a XPath starting with the XPath of the form tag.
  3. The Input GUI elements are used to build the test steps.
  4. The Action GUI elements are used to build the submit test steps.

The following GUI elements are considered Input GUI elements:

Tag Type Default Value Action
input checkbox Click
input color #FFEEXX SetColor
input date 12031976 SetText
input datetime-local 04051987|0201p SetDateTime_Local
input email random string @a.ch SetText
input file c:/temp/log.txt
input hidden
input month 11|1234 SetMonth
input number random number SetText
input password random string SetText
input radio Click
input range random number (0.0, 100.0) SetSliderH
input search random string SetText
input tel 0152 12345678 SetText
input text random string SetText
input time 0205a SetText
input url http:// random string SetText
input week 122008 SetText
select first entry SelectByIndex
select multipe first entry
second entry
SelectByIndex
textarea random string SetText

The following GUI elements are considered Action GUI elements:

Tag Type Default Value Action
button Click
input button Click
input image Click
input reset Click
input submit Click

Parent Tag Test Generators

The approach used to build the Form Test Generator can be generalized in the following way:

  1. find a parent tag
  2. group the child tags into test relevant and others
  3. set an action and a default value if necessary
  4. order the test steps

Using the information stored for each GUI element in the database makes it very easy to build this type of test generator.
Parent tag test generators can be created using the GUI.
The steps are:

  • Switch to the Test Block tab.
  • Perform a GUI element search
  • In the Select Web Element dialog you can
  • Select the parent tag GUI elements and click Generate Test using Tag List.
    This will create the tests using the form tags and the tags defined in MyTagList.

  • Click on Create Customized Tests.
  • In the Add Tag Template dialog you can define how a particular tag is converted into a test step.
  • Click Generate to generate the tests.

The use of the table in the Add Tag Template dialog is described below. The suggestions shown take into account the values entered when the table is filled from left to right.

Column Description
Tag CTRL+Space will show all tags below the parent tag.
Type CTRL+Space will show all types below the parent tag.
If the tag is set only the available types for the set tag are shown.
Attributes CTRL+Space will show all attributes below the parent tag.
If the tag and/or type is set only the attributes available for the set tag / type are shown.
Free text can also be entered. ## can be used for no name or value. e.g. class=## means that tags with a class attribute will be considered independent of the class value.
Action CTRL+Space will show all available actions.
Values CTRL+Space will show method names used to find the value. Parameters have to be entered behind the # e.g. #CheckKindOfSelection#single will check for single selection in a drop down list.
Free text can also be entered.

The parent tag test generators are very useful and powerful. For example, you can use them to validate the text in each table cell as follows:

Parent Tag: table
Child Tags: td, th
Action: CheckText
Default Value: the text stored in the database

Using the XPath as search criterium allows you to check the sorting of the table as the XPath of a GUI element will always point to the same cell of the table, regardless of the sorting.

The used CSS classes in the table can be checked by adding new Tag definitions dependent on the tags used for the formatting of the table. The action needs to be CheckAttribute and the Default Value the class attribute stored in the database. Should the main formatting of the table be in a parent tag of the table you just have to use this tag as parent tag. The rest works the same way.
The parent tag generators are only dependent on the HTML tags. They are independent of the location of the tags. They will generate tests for all parent tags (e.g. all tables) in the Web application. Any tag can be a parent tag. The same is also true for the child tags. The only rule for the child tags is: they have to be a child of the parent.

The parent tag generators will in most cases work without any changes for a new release of your web applications. You may need to change the tag attributes used or add some formatting tags. All functional tags are unlikely to change.
The parent tag generators are independent of the number of child tags. They will just create more test steps if there are more child tags and less if there are less. In other words. For example, adding the country to to a registration form will not result in a change in the form generator. The form generator will automatically add the new input field to the test.

Test Names

MyITest4U will generate the test names using the GUI element attributes in the following order:

  • speaking name
  • form action
  • display name of the GUI element

Universal Test Generators

By using only HTML elements defined by the WHATWG - Standards, you can create tests that are independent of your web application. In other words:

No maintenance is required for these tests.
A rebuild of the tests will always give you working tests.
Maintenance is only required if the HTML standard changes.

An example of a universal test generator is:

Parent Tag: table
Child Tags: td, th
Action: CheckText
Default Value: the text stored in the database

An example of a not universal test generator is:

Parent Tag: table
Child Tags: td, class="text-danger"
Action: CheckText
Default Value: the text stored in the database

The last test generator would check the text of table cells using a red color as defined by the class value "text-danger".
The class value "text-danger" is not defined in the WHATWG - Standards. It might change in a future release.

Complex Parent Tag Test Generators

There may be situations where using the built-in parent tag test generators does not produce a runnable test block. Some of these complex situations can be solved by programming your own generator. The main programming steps are the same as for the built-in generators. A sample code that can be used as a starting point can be found in the following classes:

Class Description
AllMyTests Gets the GUI elements and transforms them to test steps
AllMyTestsGenerator Gives access to the list of generated test steps
TdTagTemplate Contains tag definition, default action and value. The tag definition is used to find matching GUI elements.
MyWebGenerator Constructs the generator and does the test generation.
MyWebGenerators Add everything together and makes the generators visible in the main menu.
MyTagTemplateList Contains a list of all TagTemplates.
MyWebGenConfig Matches the TagTemplates to GUI elements.

Click All Clickables On A Page

This test generator creates a test that clicks all clickables on a page for each URL of the AUT.
BrowserBackUrlChanged is done after clicking each clickable. Global / Local Excludes can be used to exclude clickables from the test generation.
The generated tests can be used to collect more GUI elements.
Further they can be used together with the Universal Check Points of MyITest4U as smoke tests.

Click All Clickables

This test generator creates a test that clicks all clickables of the AUT. GoToStart will be called after each click. MyITest4U will try to find the way to the clickable before clicking it. Global / Local Excludes can be used to exclude clickables from test generation.