fbpx

Effective Using of Function Libraries

Effective Using of Function Libraries

Home Forums ZAPTEST Best Practices Effective Using of Function Libraries

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #30844
    Valentin ZAP
    Keymaster

      ZAPTEST enables the use of external libraries (collection of functions or procedures). We can include libraries not only from local PC, but also from HP ALM and CA Agile Central servers.

      Q. How does the “Include” method work?

      Before executing the script ZAPTEST is looking for function libraries and then Includes them before executing. Therefore we should put the Include methods at the top of the scripts as the first lines of code.

      In case of Javascript: make sure to write each Include method on its own line. combining them into a single line will cause ZAPTEST to ignore the statements.

      Q. Could we use cross-script variables for implementing Include logic?

      No. We can use only global variables. But don’t forget that ZAPTEST doesn’t have concrete including order for functional libraries (Include method) like C/C++ languages. ZAPTEST includes all function libraries before executing the script. Just like if we put them to ZAPTEST Options (Tools -> Options -> Function Libraries)

      Q. We cannot use If statement for Include method. But how to implement complex logic?

      Yes, we cannot use Include method insight method or If statement. But we can use local variables for that:

      ‘ base folder
      rootFolder = “c:libraries”
      libraryName = “PC.zap”

      ‘ in case of android
      If Datatable.Value(“device”) = “android” Then
      ‘ change path
      libraryName = “Android.zap”
      End If
      Include rootFolder & libraryName

      ‘ some code

      Q. Can we use Datatable values as parameter of Include method?

      Sure. We can use Datatable values. Each iteration the value updates to current table row.

      Include someVariable & Datatable.Value(“library”)

      Q. What about GetGlobalVar and GetLocalVar methods?

      We can use them like Datatable.Value method.

      Include baseFolder & GetGlobalVar(“device”) & “.zap”

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.

    Virtual Expert

    ZAPTEST

    ZAPTEST Logo