18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Calling/Creating Custom Global Functions

kphapakdykphapakdy Members
edited July 2010 in Sahi - Open Source
From reading and researching through the forum I wanted to make sure that I understand correctly regarding creating custom global functions and calling them.

1) To create custom global functions, I would need to add it to c:\sahi\htdocs\spr\extensions.js. Is this the only location that I may add global custom functions? Can I have multiple .js files for differentiate between components, i.e. search.js, reports.js, etc.


2) To call the global functions I need to include it in my script, i.e.

would it be:

_include("extensions.sah"); or
_include("lib.sah"); or

Thank you.

Kai

Comments

  • narayannarayan Administrators
    No Kai, you can (and should) have functions in just any other sah file, and use _include to include it. Where did you see the extensions.js part? It is incorrect and needs to be corrected if it is on this website. Create multiple files for different modules/pages, and use then where necessary using _include. Keep these files normally with other sah files (eg. in the scripts folder).
  • Thank you. When you edit extension.js file, this is what is displayed:

    **
    * Copyright 2006 V Narayan Raman
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    // you may add your custom global functions here
    // uncomment line which includes extensions.js in config/inject_top.txt
Sign In or Register to comment.