Creating a Custom Command

From GXtest Wiki
Revision as of 18:21, 10 January 2011 by Ftoledo (Talk | contribs)

Jump to: navigation, search


Custom Commands give GXtest the flexibility to create new commands expressing action or validations to be performed in JavaScript language.

Creating a Custom Command

Open this menu to create Custom Command.

AccesoCustomCommand.jpg

The following screen will open where you can enter the JavaScript code to be run when the command is run:

CodigoCustomCommand.jpg

You need to choose a name, which will be used to reference it, and a description of the command.

Then you must choose the kind of command:

  • Action
  • Event
  • Validation

Then you need to choose for which versions of GeneXus the command is valid.

In the JS text box, a JavaScript template is displayed that must be respected in order to implement the command.

If the JavaScript function is implemented it is possible to consult values from (v8, v9, v10, undefined) and currentLanguage (java, net, undefined) if it is necessary that different actions are necessary depending on these parameters. Además se les puede pasar un parámetro en ParamJS.

You will recieve OK from the result variable if everything went well or an error message if it failed.


In the following example you can see how to use the information provided by GXtest in the parameters, taking different actions according with the generated language (java or dot net).


if (currentLanguage=="Java") {


} else if (currentLanguage=="net") {


} else {


}


You can do something similar with the GeneXus version.

Using a Custom Command

Once you have created a Custom Command it is ready to be used by GXtest the same way as any other native command, allowing you to add it and edit it manually.

The only limiting factor is the fact that you can't record it automatically using the toolbar.

Useful suggestions

In order to creat the JS function easier, you can use any tool like Web Developer from Google Chrome, or Firebug in Firefox, to look the elements which you can use to do different actions.

For example, if we want to do a command to access a menu developed with JavaScript, with these tools we can see how the navegation is performed, even if it is done with an event of if it is generated with a dinamic link.

After that you have to see how this Javascript works. If the menu is allocated on memory, perhaps it is better to interact with javascript directly with that objects. If it is not, you should interact with the 'document' object, or with 'this', to ask for an specific object on the html.