Skip to content

How to setup models for UI and Service test

David_Chau edited this page Feb 7, 2019 · 12 revisions

Defining UI test model

This section shows examples of how to specify page element and a location value. Web driver interacts with the page based on how we define our model objects. The codeless framework creates page object model for each ui model files under test. This model files need to have a correct yaml structure as shown below.

Example yaml file : "examplepage.yaml"

button:
    by: "id"
    locator: "searchbutton"
username:
    by: "name"
    locator: "username"
login:
    by: "xpath"
    locator: "/html/body/app-root/app-login/div/div/div[1]/form/div[11]/div/button"
blank:
    by: "css"
    locator: "input[value='TEST']"
browse:
    by: "classname"
    locator: "btn-primary"
slack:
    by: "name"
    locator: "slackNotification"
register:
    by: "linktext"
    locator: "registerButton"
createAccount:
    by: "partiallinktext"
    locator: "create"

save your model files as yaml files in the models folder of skeleton project with above format.

Defining service test model

This section shows examples of how to specify service calls. The service model must be named "swagger.yaml". This model files need to have a correct yaml structure as shown below.

Example yaml file in Customer folder: "swagger.yaml"

swagger: '2.0'
info:
  description: '"Fake Online REST API for Testing and Prototyping"'
  version: 1.0.0
  title: JSON Placeholder REST API
  contact:
    name: Test
    url: 'https://localhost/test'
    email: [email protected]
  license:
    name: Apache License Version 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0"'
host: 'http://dummy.restapiexample.com'
paths:
  /api/v1/employee/{id}:
    get:
      tags:
        - albums-resource
      summary: getAlbums
      operationId: getAlbumsUsingGET
      produces:
        - '*/*'
      responses:
        '200':
          description: OK
          schema:
            type: integer
            format: int64
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
  /api/v1/create:
    post:
      tags:
        - albums-resource
      summary: getAlbums
      operationId: getAlbumsUsingGET
      produces:
        - '*/*'
      responses:
        '200':
          description: OK
          schema:
            type: integer
            format: int64
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found

Using the UI test model and service test model

In the example above, if there is a web element on a page with: id = searchbutton, you can declare that element as a button, by specifying that the locator is of type id. The example above also demonstrates other ways of declaring web elements, such as by name, xpath, etc...

Refer to the element you want to interact within your test case steps, in the Target column. For example, when attempting to refer to the browse element defined above, and assuming this file had the directory of models/example/examplepage.yml, the Target column in the test sheet would contain: example.examplepage.browse

Example UI test sheet name : "t-test1".

Step Action Target Input Overrides
config setup config
POST call to customer api serviceCall customer.api.v1.create POST body::string::{"name":"etp","salary":"123456789","age":"100"}
GET call from customer api serviceCall customer.api.v1.employee.{id} GET path::id::123
Navigate to UI page goto https://example.com
click button click example.examplepage.button
close browser close