parameterization of a “set of scripts” - jscript

I have 1 project for my automation in testcomplete. This project contains all the scripts which are organised according to our need like 1 folder contains 10 scripts , another folder contains 15 scripts and so on.
We are facing the problem where in when we want to check specific pre conditions before running the set of scripts. For Ex: 1st folder having 10 scripts , they should only run when the machine has Win7 OS , MS Office 2007 & IE version 10.
It is kind of parameterization of a “set of scripts”. It is not keyword word based automation. It is completely scripting based. We are using Jscript as the scripting language.

The only way I see is to create a special "runner" script for every bunch of scripts. This script will check the required conditions and if they are met, subsequently run tests from the corresponding group. You will need to run all these runner scripts (e.g. using test items), but only those that satisfy current environment conditions will actually work and the rest will exist immediately.
Update:
For example:
function testSet1()
{
// If environment does not suit for the test set, just exit
if (false == UtilityScripts.CheckEnvironmentForTestSet1())
return;
test1();
test2();
test3();
}
The code of the CheckEnvironmentForTestSet1 routine should perform check for OS, installed software and whatever you need.

Related

Problem communicating with 3rd party apps via VBA on Mac M1

I have created a VBA add-in for Microsoft Word. Both a Windows and Mac version. The add-in communicates with 3rd party apps.
This has worked fine for years. I'm now struggling making this work for the Mac-version with M1-based macs (Maybe also Big Sur related).
The communication works partly via a dylib written i c, via stdin and stdout.
Secondly some functions use AppleScriptTask.
I can't make either of these two methods work.
AppleScriptTask always return the error:
Run-time error '5'
Invalid procedure call or argument
VBA-code:
s = AppleScriptTask("WMscript.scpt","Test","")
I tried scripts with .scpt, .scptd and .applescript.
Also newly created scriptfiles with simple test.script:
on Test(paramS)
tell application "Finder"
activate
end tell
end Test
The api works in other applications, but I can't open 3rd party apps in it when used from VBA.
I use these special folders for the all the 3rd party files to circumvent sandboxing for both methods:
/Library/Application support/Microsoft/Office365/User Content/Add-ins/
~/Library/Application Scripts/com.microsoft.word/
~/Library/containers/com.microsoft.word/Data/
I also tried the GrantAccessToMultipleFiles(FileArray) function. It always returns 'True' regardless which filenames are sendt in the array. It never prompt the user.
Running:
M1 Mac
Big sur 11.6 (M1)
Microsoft Word for Mac 16.54 (21101001)
Not sure following will help you.
If your third-party application is from unknown developer, then it goes to GateKeeper quarantine. Try to remove quarantine before calling your VBA script, running following script.
set theApp to application id "Avidemux.org" -- EDIT here the bundle ID
set quotedPath to quoted form of (POSIX path of (path to theApp))
do shell script "xattr -rd com.apple.quarantine " & ¬
quotedPath with administrator privileges
You can include the code above to beginning of your VBA script.
The ApplceScriptTask problem was related to an incorrect path, for the script file:
Incorrect: ~/Library/Application Scripts/com.microsoft.word/
Correct: ~/Library/Application Scripts/com.microsoft.Word/
Had to be Uppercase W.

integrating protractor with Jenkins

When I want to run specific test or suites. I run them from terminal.
I've installed jenkins and configured my first free style project.
I added shell command (ex: protractor conf.js --suites A --params.user =A).
Everything works fine. If I want to run multiple suites I must edit my shell command inside jenkins. Is there any workaround?, like checkboxes, so I can check which suites I want to run.
Also I want to know about extensible parameters. I want to select which parameters I want to run. Instead of putting command protractor conf.js --params.user=oneuser I want to be able to choose it from GUI.
Look into parameterized builds.
"First, you need to define parameters for your job by selecting "This build is parameterized", then using the drop-down button to add as many parameters as you need."
"String parameters are exposed as environment variables of the same name. Therefore, a builder, like Ant and Shell, [or protractor] can use the parameters."
So if you make "protractorSuites" a string parameter, you can reference it like:
protractor conf.js --suites ${protractorSuites} --params.user =A
Then when you "Build with parameters" you can supply the appropriate suite.

Searching all Business components by functions they use, in UFT

Is there an easy way to see all the Business components that are using a specific function in UFT or ALM?
There is a function which was scripted in my library and now i want to delete that function from my library.
If i delete the function from my script without removing it from all the business components that use it, my test could fail.
I'd add some code to the function like so:
Dim oUft : Set oUft = CreateObject("QuickTest.Application")
Reporter.ReportEvent micWarning, _
"<YourFunctionName>", _
oUft.Test.Name & " uses function <YourFunctionName>"
That means that every time this function is called, it will output the test name to the test results. Run with this for a week, or however long your test cycle is to make sure you have executed a full suite of tests, then scan the reports to identify all the tests using it.
All of my UFT scripts write their own text log files as I don't use the Test Results option - if you do similarly, then you could simply grep the log files for the message.

Is it possible to incorporate an environment variable into a ruby script for Calabash?

I am testing a feature on an app that requires the user to be a certain age. The only time you see the prompt that asks for your age is once you open the app for the first time and once you log out of the app. I don't want my test to only go through my steps to log in and then log out to be able to see this prompt, but I also don't want to manually reset the data in between tests either. Isn't this why we write scripts? Anyways, before I launch the test, I use the environment variable RESET_BETWEEN_SCENARIOS=1 cucumber features/my_feature.feature. Is there a way that I can use this variable INSIDE of my step definition so that it resets the data on its own once I run the script?
I'm not familiar with Calabash, but it appears to be using cucumber. If that is the case, you could handle the action in a before or after hook which would run before or after each scenario.
Within the features/support folder, add a file hooks.rb
Before() do
if ENV['RESET_BETWEEN_SCENARIOS'] == '1'
#code to reset data
end
end
This could also be run after the scenario by using After() do. The same if/then could be used within a scenario step as well.

Powershell: commandline applications not working after calling method from module

I have created a powershell module (.psm1) file that includes a few other powershell scripts. We use it for sharepoint.
So basically, here's what happens:
I have a deploy script that retrieves the module location from the registry
It loads the module using the Import-Module cmdlet (using -force switch)
This module in turn loads the Sharepoint 2010 snap in and a few other scripts that I created
It runs runs a deployment script that references functions from the included scripts
It also runs a command line application and sends the output directly to the screen
The script will usually work the first time. However, after a few number of tries the commandline tool will stop working and sending output to the screen altogether. And if I try to run a commandline tool (not a cmd-let) after running my script, it don't worky anymore: no output, nothing is done. Its just the same as hitting enter on a blank prompt. anything powershell specific or running GUI applications will work fine but running any console application will not produce any concievable results. the only solution to this, is to just close my powershell and open it again. it will work for usually once and I will have to close it again. our users certainly wont be happy about that..
The most 'notable' things on the script:
scriptblocks are used extensively (for logging), a script block is sent to a handler that executes it using invokecommand and logs the step
its manipulating sharepoint objects
all objects are properly disposed of
no static variables are created nor changed
There are a few global variables shared across all scripts
What I have tried:
I striped my code to a bare minimum: loading an xml file, and restaring a few windows services but I'm still getting this intermittently. I have no idea which part of the code could cause this. I would love to post the code, but our company policy forbids me to. so my aplogies..
Update as per the comment below:
here's roughly how I use codeblocks. I have this function below that is used everytime I want to make the user aware of a task that I'm executing and what it outcome is.
function DoTask($someString, $scriptBlock, $param)
{
try
{
OutputTaskDescription $someString
InvokeCommand $scriptBlock -ArgumentList $param
OutputResultOK
}
catch
{
OutputResultError $_.tostring()
}
}
it could then be used like this:
$stringVar = "something"
$SpSite = new-spsite
deploySomething 'Deploying something' -param $spsite -ScriptBlock {
dosomethingToObject $stringvar
dosomethingToObject $spSite.Name
}
it would then output something like:
Deploying Something ------------- OK
Deploying Something ------------- ERROR
Also notice that I pass the $spsite in the argument list and I just use the string directly. I still don't understand how this works but it seems like I can access all primitive typed variables even without passing them as arguments but I have to pass more complex objects are params, else they dont have any value.
Update:
after much searching and days of pain. I have found others with the same pain. My code exhibits the same exact symptoms as described here:
http://connect.microsoft.com/PowerShell/feedback/details/496326/stability-problem-any-application-run-fails-with-lastexitcode-1073741502
I guess there is no solution yet to this problem.
After a little while I've noticed that if I've ran some very memory intensive functions, I too have gotten that behavior where everything you try to execute just goes to the prompt again. I'd recommend setting Set-PsDebug -Trace 2 to see what those functions are actually doing. I fixed my issue by doing this and figuring out how to make my functions more efficient.

Resources