Difference between revisions of "Creating a Test Case with Variables"

From GXtest Wiki
Jump to: navigation, search
(Página nueva: __NOTOC__ Category:GXtest Guides ==Introducción== Hay veces que es de interés tomar valores devueltos por la aplicación para luego utilizarlos en otro lado de nuestro caso de ...)
 
Line 2: Line 2:
 
[[Category:GXtest Guides]]
 
[[Category:GXtest Guides]]
  
==Introducción==
+
== Introduction ==
Hay veces que es de interés tomar valores devueltos por la aplicación para luego utilizarlos en otro lado de nuestro caso de prueba.
+
Sometimes it is necessary to take values returned from an application and use them in a different part of a Test Case.  
 +
To accomplish this you can use variables. In this tutorial you will create an example called DuplicateClient. The Test Case's objective is that no two clients are allowed to enter with the same ID.  This can be done be making a Test Case using the following steps:
 +
# Go to the Work With Clients Page.
 +
# Load into the variable the ID of the first client on the list
 +
# Click the button that allows you to create a new client
 +
# Enter the value captured before for ID of the client and then enter a name
 +
# Click Accept and make sure that the application brings up a window that says that this ID already exists
  
Con este fin se han creado las variables. En este caso en particular veremos el ejemplo que denominamos ''ClienteDuplicado''. El caso de prueba tiene como finalidad probar que la aplicación no deje ingresar dos clientes con el mismo id. Para esto vamos a grabar un caso de prueba que realice los siguientes pasos:
+
== Creating the Test Case ==
# Voy a la página de trabajar con clientes
+
Now you'll see the steps to be followed in GXtest Designer and GXtest Recorder. First open the GXAjaxSample9 project from where you were working with GXAjaxSample and tell GXtest Designer that you want to record a new Test Case that will be called DuplicateClient. Then press Enter which will open a browser window. Once you are on the Start page, click on the Work With Clients link.
# Cargo en una variable el id del primer cliente que se lista
+
Now you need to get the value returned for the ID of the first client (in this case 5) by selecting it with the mouse and then clicking on the button [[Imagen:ButtonTake.jpg]] as seen in the following image:
# Presiono el botón que me permite crear un cliente
+
# Ingreso en Id de cliente el valor antes capturado e ingreso un nombre cualquiera
+
# Presiono confirmar y valido que la aplicación me despliegue un mensaje de que el identificador ya existe.
+
  
== Crear el caso de prueba ==
 
Ahora vemos como hacemos estos pasos con GXtest Designer y GXtest Recorder.
 
Primero que nada entramos al proyecto GXAjaxSample9 en el que venimos trabajando con GXAjaxSample y le indicamos a GXtest  Designer que queremos grabar un nuevo caso de prueba al cual denominaremos ClienteDuplicado. Luego presionamos enter para que se nos abra el navegador. Una vez que estemos en la página de inicio hacemos clic en el link WorkWithClients.
 
 
Ahora tenemos que obtener el valor del id del primer cliente devuelto (en este caso es 5), para eso lo seleccionamos con el mouse y hacemos clic en el botón [[Imagen:ButtonTake.jpg]] tal como se muestra en la siguiente imagen:
 
 
[[Imagen:buttonTake2.jpg|center]]
 
[[Imagen:buttonTake2.jpg|center]]
  
Al hacer clic se desplegará la siguiente ventana en la cual indicaremos el nombre que le queremos poner a la variable (en este caso le pusimos IdClienteExistente) y el criterio por el cual tomamos la primera fila (en este caso dejaremos ByRow con valor 1 para indicar que es porque era la primera fila):
+
Upon clicking, a new window will appear where you can enter the name of the variable (in this case ExistingClientId) and the criteria that says you want the first row (in this case you will leave the ByRow value as 1)
  
 
[[Imagen:CaputreValueWindow.jpg||center]]
 
[[Imagen:CaputreValueWindow.jpg||center]]
  
Ahora presionamos el botón (+) para ingresar un nuevo cliente. Una vez que se abra la pantalla de ingreso de nuevos clientes ponemos el valor 5 en el campo Id e ingresamos un nombre cualquiera. Al presionar confirmar para dar efectivamente de alta al cliente se nos abre la siguiente ventana:
+
Then click the + Button to enter a new client. Once the screen opens put 5 as the value in the ID field and enter a name. Now click Accept to discharge the client and open the following window:  
  
 
[[Imagen:variableWindow.jpg|center]]
 
[[Imagen:variableWindow.jpg|center]]
  
Dicha ventana nos pregunta si queremos usar el valor que guardamos previamente en vez de usar el valor fijo 5. En este caso como justamente lo que se busca es eso, presionamos el botón si.
+
This window asks you if you want to user the saved value instead of the fixed value of 5. In the case this is exactly what you want to happen so click Yes.
  
Volvemos a presionar el botón confirmar de la pantalla de alta de cliente y la misma nos desplegará un cartel en rojo que dice: "Record already exists"
+
Click the Accept button again on the discharge screen and a red warning that says: "Record already exists"  
  
Seleccionamos el texto que aparece y agregamos una validación del tipo AppearText presionando el botón [[Imagen:ButtonValidations.jpg]]
+
Select the text that appears and add an AppearText validation by clicking the button  [[Imagen:ButtonValidations.jpg]].
 +
 
 +
Then close the window to stop recording. The Test Case that you obtain ought to look like the following:
  
A continuación cerramos el navegador para terminar de grabar.
 
El caso de prueba que obtenemos al finalizar se muestra en la siguiente imagen:
 
 
[[Imagen:ClienteDuplicado1.jpg|center]]
 
[[Imagen:ClienteDuplicado1.jpg|center]]
  
Si observamos en la arista Click "Insert", se está utilizando el comando GetValueTable para indicar el valor que se debe tomar de pantalla y el nombre que se le debe asignar.
+
Looking at the Click “Insert” Edge Line, it is using the GetValueTable command to indicate the value that it ought to take form the screen and the name that it ought to assign.  
 
+
Luego si se selecciona el nodo Client se puede ver que en el comando FillInput se pasa la variable antes definida.
+
  
==Probar el caso de prueba==
+
Then if you select the Client Node you can see that the FillInput command goes to the pre-defined variable.
  
Ahora podemos ejecutar el caso de prueba y ver que efectivamente el sistema no permita ingresar identificadores repetidos.
+
== Testing the Test Case ==
Si hacemos la prueba de borrar el primer cliente (el que usamos mientras grabamos) y ejecutar nuevamente veremos que el caso de prueba igualmente funciona ya que no tiene fijo los datos que utiliza durante la prueba.
+
Now you can run the Test Case and see that the system doesn’t allow you to enter repeated IDs.  If you have the test to delete the first client (the one you used when recording) and run the test again you will see that the Test Case still works even though the data from the test are not there.

Revision as of 23:16, 30 November 2009


Introduction

Sometimes it is necessary to take values returned from an application and use them in a different part of a Test Case. To accomplish this you can use variables. In this tutorial you will create an example called DuplicateClient. The Test Case's objective is that no two clients are allowed to enter with the same ID. This can be done be making a Test Case using the following steps:

  1. Go to the Work With Clients Page.
  2. Load into the variable the ID of the first client on the list
  3. Click the button that allows you to create a new client
  4. Enter the value captured before for ID of the client and then enter a name
  5. Click Accept and make sure that the application brings up a window that says that this ID already exists

Creating the Test Case

Now you'll see the steps to be followed in GXtest Designer and GXtest Recorder. First open the GXAjaxSample9 project from where you were working with GXAjaxSample and tell GXtest Designer that you want to record a new Test Case that will be called DuplicateClient. Then press Enter which will open a browser window. Once you are on the Start page, click on the Work With Clients link. Now you need to get the value returned for the ID of the first client (in this case 5) by selecting it with the mouse and then clicking on the button Imagen:ButtonTake.jpg as seen in the following image:

center

Upon clicking, a new window will appear where you can enter the name of the variable (in this case ExistingClientId) and the criteria that says you want the first row (in this case you will leave the ByRow value as 1).

|center

Then click the + Button to enter a new client. Once the screen opens put 5 as the value in the ID field and enter a name. Now click Accept to discharge the client and open the following window:

center

This window asks you if you want to user the saved value instead of the fixed value of 5. In the case this is exactly what you want to happen so click Yes.

Click the Accept button again on the discharge screen and a red warning that says: "Record already exists"

Select the text that appears and add an AppearText validation by clicking the button Imagen:ButtonValidations.jpg.

Then close the window to stop recording. The Test Case that you obtain ought to look like the following:

center

Looking at the Click “Insert” Edge Line, it is using the GetValueTable command to indicate the value that it ought to take form the screen and the name that it ought to assign.

Then if you select the Client Node you can see that the FillInput command goes to the pre-defined variable.

Testing the Test Case

Now you can run the Test Case and see that the system doesn’t allow you to enter repeated IDs. If you have the test to delete the first client (the one you used when recording) and run the test again you will see that the Test Case still works even though the data from the test are not there.