Multiple Scripts folders and Network Share
Multiple Scripts folders
question
How can we support multiple Scripts folders?
answer
To keep scripts at multiple locations, the following is important.
This is how you can specify this top level scripts folder.
Controller
- There should be NO hardcoded absolute paths in your scripts at all. Always use relative paths.
- Also don't use _userDataDir().
This is how you can specify this top level scripts folder.
Controller
-
Take a backup of
userdata/config/userdata.properties
. -
Edit userdata.properties. Edit the following line
and add any path that you want to set as the scripts folder. Let us say, we addscripts.dir=scripts;
D:/temp/scripts
.scripts.dir=scripts;D:/temp/scripts;
- Restart Sahi server.
-
Now if you go to the Controller Playback tab, you will see D:/temp/scripts in the
Script Directory:
dropdown. You can choose this folder and run your script and it will work relative toD:/temp/scripts
.
- The same thing can be done from testrunner.bat as well.
-
Take a backup of
userdata/bin/testrunner.bat
. -
Edit testrunner.bat. Replace this line
withSET SCRIPTS_PATH=scripts
SET SCRIPTS_PATH=D:/temp/scripts
-
Now when you run testrunner.bat, the suite/script will run relative to
D:/temp/scripts
.
- The same thing can be done from drun.bat as well.
-
Take a backup of
userdata/bin/drun.bat
. -
Edit drun.bat. Replace this line
withSET ORIG_SCRIPTS_PATH=../scripts/
SET ORIG_SCRIPTS_PATH=D:/temp/scripts
-
Now when you run drun.bat, the suite/script will run relative to
D:/temp/scripts
.
Scripts on a network share
question
- Scripts need to be kept at a central location, so that they can be run off the central location from any machine.
- At the same time, we need to have the ability to run scripts locally, since we may change scripts on individual machines to test specific things.
answer
Refer to the FAQ above for how to support multiple script locations.
Do the following steps to run scripts from a central location.
Do the following steps to run scripts from a central location.
- Put all central scripts in a central location. Let us say you copied the "scripts" folder into another folder called "shared" on the central machine.
- Share the "shared" folder.
- On every machine that runs the tests, use Map Network Drive to map the "shared" folder as a drive. Let us say this is mapped as Z: on a machine. So now the central scripts can be accessed as Z:/scripts.
- In the FAQ above, replace "D:/temp/scripts" with "Z:/scripts".