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 zaptest.com 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: demo.zaptest.com 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. Now we are ready to create our test. We have 2 ways to build it – Script or Scriptless. In this example we will build Scriptless test using Step View. 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 objects by using drag & drop of the object into the test editor. Then selecting "Launch" method to launch Chrome browser. We will add the application name "chrome" and the site URL. We will add another step 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 test, after the test finish it generate the report when we can check the result of each operation. Another big feature of ZAPTEST is PARAMETERIZATION using DATATABLES. Using PARAMETERS, we can do a few iterations of this test, for example we can run it in multiple browsers. To do that we should add some data into the DATATABLE and use it in our test. Let's change our test for launching it in two different browsers "chrome" and "firefox", ZAPTEST will execute this it 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. We will use If-Else conditional statement to proceed with typing credentials. First let’s set up IF condition Drag & drop the textboxes to the editor and use the "Type" method 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 test and we will use "Exist" method. We will add Else conditional statement ad use Custom Report method to report error Let’s check the test. Then save it 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 test is ready. Now, we can complete our DATATABLE with IE browser and run the test. We can see that we are using only one test 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

Tower Place 100

3340 Peachtree Rd NE #1800 

Atlanta, GA 30326 USA

(404) 814-5227