Running the same Katalon test case with a different parameter - katalon-studio

In our Katalon Studio project we have a test case.
We like that test case to accept a parameter from the command line when running the test suite.
For example, we like to run the same test case one time with parameter=A and another with parameter=B.
This will enable our Jenkins to run different tests without the need to duplicate test cases again and again.
Is there a way to do it?

Actually, you can't specify your parameters in the command line. But it seems to be in demand by the community (Katalon - How to pass user defined parameters from command line)
Solution :
You can define your parameters in profiles. Each profile can contains the same parameters with different values, and can be chosen during the Test Suite execution.
You can choose the profile you need manually or by passing it in command line. To do it you only have to use the -executionProfile option:
katalon -noSplash -runMode=console -consoleLog -noExit -projectPath="C:\MY_PATH" -retry=0 -testSuitePath="Test Suites/MY_TEST_SUITES" -executionProfile="Profile_A"
Finally, don't forget to convert your step input Variables into Global Variables where you need in your Test Case. You can do that manually or by script :
import internal.GlobalVariable as GlobalVariable
GlobalVariable.my_variable
docs: Katalon Docs - Execution Profile (v5.4+)
Hoping it will help you.

Like post above but in more way of showing where to look for the answers.
After You open Your Project, look for Profile :
Need to add to your script(it should be added be default be still remember if you will get error about missing keyword)
You are ready to make your "Build CMD"

From version 5.10, it is possible to override profile variables from the command line.
So, if you have a GlobalVariable.parameter=A as the default, you can add
-g_parameter=B
to the command line command to switch it to B.

Related

How do i run/import a downloaded command-line programm?

there is a command-line program called tcpvcon.exe
According to Microsofts website (https://learn.microsoft.com/en-us/sysinternals/downloads/tcpview) it should be possible to access it the following way:
tcpvcon [-a] [-c] [-n] [process name or PID]
Do I have to import this executable somehow to be able to access its commands?
I am trying to write a small script, but I am struggling to access the program in a reasonable way that allows me to pass it arguments.
I am using Powershell.
Thanks
Edit:
I downloaded the program, executed it once and accepted the licence agreement. Now I would like to be able to use the above command in Powershell.
If I use it i get following error:
"tcpvcon" is not recognized as the name of a cmdlet...
Do I have to import the cmdlet somhow? I cannot find any information on this... It is probably a very simple fix and I just do not know the procedure.
Thanks again.

how to run Pester quickly with -OutPut Detailed in VSCode?

Press the shortcut key 'Ctrl+F5' in VSCode to run the Pester test file with the suffix '.tests.ps1'.
In 'about_Parsing.Tests.ps1' After you press "Ctrl+F5", the console will directly appear:d:\GitRepository\PowerShell\example\pester\‪about_Parsing\‪about_Parsing.Tests.ps1
The test is then run directly.
How to run tests in such a convenient way and use various invoke-pester parameters, such as -output detailed?
If you go to the Settings of VSCode and search for Pester, you should find a setting called:
PowerShell > Pester: Output Verbosity
You can set this to "detailed".
The setting also indicates that if you're using Pester v5 or newer you can also set this via the $PesterPreference variable which it uses by default. You could set this variable in your script or PowerShell profile.
$PesterPreference = [PesterConfiguration]::Default
$PesterPreference.Output.Verbosity = 'Detailed'

Is there a way to pass Jenkins credentials to automation test execution command?

I have created some global credentials in Jenkins, and I want to pass them to a powershell command that starts the execution of a protractor test suite.
The credentials are created properly, the bindings are also done as you can see int he image below:
The thing is, I need these credentials to use them when running the automation tests. The powershell command that I execute is the next one:
npm run test -- --userName=${env:ECASUSER} --password=${env:ECASPWD}
After I start the job the command is called inside the windows agent as expected, triggering the tests. When the test are using those credentials to authenticate it seems they are empty strings.
In the job console log, both credentials appear to be there but displayed like this (****).
I have tried a lot of solution none of them work. Am I doing something wrong here?
After some time spent to this, I reached the conclusion that this never worked. Or maybe it did at some point but, yeah it simply stopped.
Basically, Jenkins is not passing credentials to Windows batch or Power shell commands. My automation tests were running on blanks.
The only solution, that I found to this problem, is this one:
Create a new binding: Username and Password(conjoined) - here create a new job parameter containing the credentials. Let's say the parameter is named USERPASS;
Create a new 'Windows batch command' section where you save the credentials to a file in you test project (amazingly this one works) - your credentials will be saved to the file like this: "username:password". This is how you save the credentials:
echo %USERPASS% > "%WORKSPACE%\password.txt"
Change the automation test project to retrieve the credentials from the file;
Delete the file after the tests are completed.
I believe it should have been
npm run test --userName=${ECASUSER} --password=${ECASPWD}
and make sure you don't pass unnecessary --
Let me know if that doesn't work, I have other ideas

Running a specific browser NUnit test using the command line

I am trying to run the firefox only test using the command line for NUnit but not sure how to. The code is as follow.
[TestFixture(typeof(FirefoxDriver))]
[TestFixture(typeof(ChromeDriver))]
[TestFixture(typeof(InternetExplorerDriver))]
public class TestCases<TWebDriver> where TWebDriver : IWebDriver, new()
{}
No problem with NUnit GUI since it is separated, however requirements forces us to run it with the command line. Thanks.
I'm looking into like: nunit.console.exe /fixture:"value" /xml:.. etc.. or any other implementation
Thanks!
The best way I've found to do this is to specify a category with the driver such as: [TestFixture(typeof(string), "Chrome")]
Then you can specify the category on the console arguments with nunit-console.exe foo.dll /include:Chrome

Is there a way to access TeamCity system properties in a Powershell script?

I'm trying to set up a new build configuration in TeamCity using the Powershell runner. However, I can't seem to find a way to access the TeamCity System Properties in the build script. I've seen hints that it is possible, but cannot find documentation on how to do it.
I have tried accessing the system properties using Powershell variable syntax, $variable. I have also printed out all variables in memory and see no teamcity variables to use.
Is this possible with the Powershell runner, and if so what is the syntax necessary to get it working?
TeamCity will set up environment variables, such as build.number (you can see a list of these within TeamCity).
In Powershell you can access environment variables using the env "provider", e.g.
$env:PATH
TeamCity variables are accessible by replacing the . with a _, so the build.number variable can be accessed as
$env:build_number
As it says in the TeamCity documentation, the system parameters are passed to the build script runner, but not all build script runners know what to do with them. In the case of the Powershell script runner, when using a script file, they don't propagate down to your scripts.
It's occurred to me to write a psake-optimized build runner that does, but in the meantime you can do one of the following:
explicitly map any of the TeamCity build properties to script parameters using the parameter expansion that's available within the Script Source box. eg .\build.ps1 -someParam:%build.name%
use environment parameters, which can be accessed explicitly within PowerShell using $env:NAME_IN_TEAMCITY syntax, eg $env:TEAMCITY_VERSION, or looped over and pushed into variable scope
access the build properties file that TeamCity makes available during the build. The file is available at $env:TEAMCITY_BUILD_PROPERTIES_FILE, and if you load the XML version it's fairly easy to loop through and push them all into scope (though you do get everything as a string of course). I posted a gist on how to do this (https://gist.github.com/piers7/6432985). Or, if using Psake, modify the script above to return you a hashtable which you can pass directly to Psake's -properties argument.
It is posible. Here is example how to pass system properties into PSake script:
& .\psake.ps1 -parameters #{build_number=%build.number%; personal_build=%build.is.personal%}
If you don't use Psake, you can define your variables like this:
$build_number = %build.number%
The %build.number% part will be replaced with TeamCity provided data. I think, it works only in Source code script input mode.
I created a meta-runner that will pass through System parameters to parameters declared in the Powershell script. It's not perfect (if you put '# in your source it will break) but it works for what I needed, you can find it here: https://gist.github.com/anonymous/ef60ada3f48f0fb25093