Building Your First Script

Welcome to ZAPTEST Tutorials! In this tutorial, we will show you how to create a simple test case and run it in different browsers. First, we will download and install ZAPTEST. Go to website, proceed to the downloads and then install the latest version of ZAPTEST. For launching ZAPTEST Free Edition you need to create and activate an account using the "Sign Up" tab. if you already have a ZAPTEST account you go straight to login and use your credentials. You are now ready to work with ZAPTEST! In this example, we will be using a demo website: and we will demonstrate how to automate a login page. We will start with adding a new object to our repository. Click “Scan GUI” on “GUI Map” tab. Now we should select application to scan. In our case, we will be choosing the Chrome browser with opened login page. Then we have to create new Application object and a view for the login page. ZAPTEST will create all recognized OCR objects and objects based on edge detection. For first script, we need only a few items: “title”, “username” label, “password” label along with textbox fields and the login button. We will select those items and delete unselected that we do not need anymore. Then we will rename some of the objects for better understanding of which object name relates to the real object. In case of textboxes we usually use “Relative” objects. The Username textbox should be related to the username label and the password textbox to the password label. To set relation press “Select Relative Object” button in the object properties (or on the GUI Map toolbar) and select parent object. Now we are ready to create our script. We have a few ways to write a script. we can use the "Object Repository" located at the right side or "GUI Map" located at the bottom of the screen to generate object code. Also we can type all the code from scratch. Let's start by opening the browser. There are a few classes of objects that we can use. In this lesson, we will be using two of them, "Application" and "Object". We will manipulate with "application" by using drag & drop of the object into the code editor, then selecting "Launch" method to launch Chrome browser. We will add the application name "chrome" and the site URL. We will add another line to close the application. It will be the same application object but with a different method: "Close". Next, we will manipulate with "Object" by clicking it, typing some text or checking if this object exists and some other manipulations. For this example, let's check that “title” object exists. Drag it from the GUI Map and select method "Exist". We are ready for our first execution. Click Run button in the toolbar and ZAPTEST will run this script, after the script finish it generate the report when we can check the result of each operation. ZAPTEST supports all features of Visual Basic and Java Script languages. In this tutorial, we are using VBScript. We can create some variables and use them in the code. Another big feature of ZAPTEST is PARAMETERIZATION using DATATABLES. Using PARAMETERS, we can do a few iterations of this script, for example we can run this script in multiple browsers. To do that we should add some data into the DATATABLE and use it in our script. Let's change our script for launching it in two different browsers "chrome" and "firefox", ZAPTEST will execute this script for us. We are ready to write a real test case for the "Login" page. Rename two DATATABLE columns to "Username" and "Password" this will allow us to use a different username and password, for each iteration. Drag & drop the textboxes to the code-editor and use the "Type" command for entering the username and password PARAMETERS from the DATATABLE. Add the "login button" object and select the "Click" command. We may also add an additional click to the title to prevent the browser from helping us entering the username and password or to prevent a security hints. How can we check that the user is logged in? We can find an object on the page that appears when the user is logged in, like the welcome message. Let’s add it to our test - click “Scan Application” button on the left toolbar in the “GUI Map” tab, create new view, select and keep Welcome Message. Now we can add new object from this view to our script and we will use "Exist" method. Let's check the script. Save the script and click Run button. ZAPTEST log in to the demo website in two different browsers, check the welcome message and generate the results. Now we are going to handle some conditions when the username or password is wrong. We are going to add a new column to the DATATABLE - "RealUser", here we will use "True" value for correct user credentials and "False" for wrong login or password. We change password in 2nd line to incorrect one. We will add new If-Else statement to validate an error message. In order to check the error state we need to also add new view like we did in the previous step. Open the demo website, enter the wrong login or password and create a new view with the error message, here we only need one object - "error message" object. Now we need to add validation of this object to the If-Else statement. Our script is ready. Now, we can complete our DATATABLE with Opera and IE browsers and run the script. We can see that we are using only one script for cross-browser execution. For more information about ZAPTEST features and functionalities please navigate to our How-To portal either through Forum page on the ZAPTEST website or through ZAPTEST Help. Thank you for using ZAPTEST!

Contact Us

3150 Roswell Rd NW

Atlanta, GA, 30305, USA

(800) 795-3552