selenium - created variable but doesn't seem available - file-upload

I want to set a variable $import_location so that I can set it once for many uses and not hard-code it into each test case that is doing file uploads.
I have the variable set OK with the store command.
I am trying to use it on the uploads screen but keep getting the literal ${variable name}
How can I set the import location to be the variable that I've set above?

I just hadn't run the actual 'variable setting' script. One I had run it and created the variable I was able to use it OK.

Related

How to save result from OS Process Sampler to a variable?

JMeter OS Process Sampler is set up, works fine and saves result (a token as result of powershell srcipt execution) to a file.
Is it possible somehow to save result from powershell script directly into a JMeter variable instead?
What should I add for that?
Normally you should be using JMeter Post-Processors in order to extract data from Sampler's responses
If the token is the only thing that your powershell script returns you can extract it using i.e. Boundary Extractor, just provide desired variable name and leave everything else empty
Demo:
If there is some other text surrounding the token - adjust the boundaries accordingly or go for Regular Expression Extractor

List all bamboo variables in inline script

I have alot of Bamboo variables defined due the fact that i have a system with alot of legacy and config at places where it does not belong. Getting rid of all this will take a bit longer on the roadmap so i need to find a way to auto replace all these values.
The number im talking about is that there are 8 customer config files with each about 100 variables. Indeed, there was a maniac who added all of those in Bamboo because as you might thought most of them are variable for each environment.
At this moment i want to automate the deployment process and all is going fine exact the fact that i need to replace 100 variables and i dont want to maintain it in my script itself all the time.
I am looking for a way to retrieve all the variables in an array so i can just iterate through all the keys and try to replace them at the config files.
echo "${bamboo.application.myvalue}" will replace the value as expected. The only problem is, how can i get all the keys under bamboo.*
I tried it with the following functions but all without success:
printenv
env
declare
All above without success. How can i retrieve a list of all those variables as inline script in Bamboo.
Thanks alot
I think it is not possible to change the value of the variables on the fly. Instead, you can use the "Inject Bamboo variables" task in order to be able to change the variable value.
This task reads a file to create the variables. So, all you have to do is to create this file with the values you need, and then use this variables.
E.g.: Creating a file from a powershell script:
$path = 'bambooVariaveis.properties'
$connectionstringX = 'connectionstring="Data Source=XXXX;"'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
[System.IO.File]::WriteAllLines($path, $connectionstringX, $Utf8NoBomEncoding)
E.g: Inject Bamboo Variables config
Using it (in a subsequent script task):
echo ${bamboo.inject.connectionstring}

Trying to run a Directory.Exists() with a system variable vs drive letter

I am trying to run a C# program to determine if a directory exists on multiple servers, so I need to run it as %system Variable%, rather than making a drive letter call, since not every server will have the same drive letter. This is what I have:
If My.Computer.FileSystem.DirectoryExists("D:\backup") Then
This code will work, as I define the drive
If My.Computer.FileSystem.DirectoryExists("%BCK_DRV%\backup") Then
This will not, I get my else error when running it. The %BCK_DRV% is defined in the environment variables, and I can navigate to the folder without issue using %BCK_DRV%\backup. Is there a special way to set and define a %drive% in C#?
Environment.GetEnvironmentVariable?
Code sample:
Dim backupDrive As String = Environment.GetEnvironmentVariable("BCK_DRV") & "\backup"
If My.Computer.FileSystem.DirectoryExists(backupDrive) Then
Try Environment.ExpandEnvironmentVariables():
string raw = #"%BCK_DRV%\backup" ;
string expanded = Environment.ExpandEnvironmentVariables( path_raw ) ;
Naturally, it's up to you to ensure that your process inherits the correct environment.
To expand "%BCK_DRV%\backup" to it's real value you need
Environment.ExpandEnvironmentVariables();
Example:
Environment.ExpandEnvironmentVariables("%winDir%\test")
will expand to "C:\Windows\test" (on my system).

BeanShell PreProcessor updates User define variables

I'm very new at JMeter issues.
In a test script i have a BeanShell PreProcessor element that updates some variables previously defined at a "User Defined Variables" element.
Latter those variables are used in "Http Requests". However, the value that is used in the http request is the default one.
The scripts seems to be working due to some debug print();
My question is if it's necessary to delay the script to be sure that the BeanShell finishes?
Thanks a lot for your attention
There is no need to put any delay to Beanshell Pre-Processor as it's being executed before request. I'd recommend to check your jmeter.log file to see if there are any scripting issues as Beanshell Pre-Processor does not report errors anywhere including View Results Tree listener.
There are at least 2 ways to assure that everything is fine with your Beanshell script:
Put your debug print code after variables replace logic to see if it fires
Use JMeter __Beahshell function right in your HTTP request. If it's ok - View Results Tree will demonstrate beanshell-generated value. If not - the field will be blank and relevant error will be displayed in the log.
Example test case:
Given following Test Plan structure:
Thread Group with 1 user and 1 loop
HTTP GET Request to google.com with path of / and parameter q
If you provide as parameter "q" following beanshell function:
${__BeanShell(System.currentTimeMillis())}
and look into View Results Tree "Request" tab you should see something like:
GET http://www.google.com/?q=1385206045832
and if you change function to something incorrect like:
${__BeanShell(Something.incorrect())}
you'll see a blank request.
The correct way of changing existing variable (or creating new if variable doesn't exist) looks like
vars.put("variablename", "variablevalue");
*Important: * JMeter Variables are Java Strings, if you're trying to set something else (date, integer, whatever) to JMeter Variable you need to cast it to String somehow.
Example:
int i = 5;
vars.put("int_i", String.valueOf(i));
Hope this helps.
You can update the vale of a "user defined variable".
You have to create a bean shell sampler
vars.put("user_defined_variable", "newvalue");
#theINtoy got it right.
http://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell
I'm new to jmeter too but as I know variables defined in "User defined variables" are constants, so you can't change them. I recommend to use "User Parameters" in preprocessors or CSV Data Set Config.

How to use a variable created by later test suite in Robot framework?

I have following test suite structures in my mind:
Test Suite 01, has one test case (TC01) in side.
Test Suite 02, has one test case (TC02) in side.
Variable file available and imported both Test suite as resource.
Variable file has one List #{List}, with several values
In TC01, I output the content of #{List}
In TC02, I first Remove ${List} index 0, and set it as a new variable with same name: Remove From List ${List} 0, and then ${List}= Set Variable ${List}, Set Global Variable ${List}
Then out put new ${List}
--> Everything works out correctly till then:
After TC02 finished, I made RF perform TC01 again, and this time I think it should use new ${List} value, but it's not. Because Variable File has higher priority.
How can I made TC01 use new global variable ${List} later in second time?
Is that possible?
Thank you very much in advance.
Well, finally I solve this problem.
Before reboot save the needed variable and value into sqlite db, and fetch them after reboot.
What you are probably looking for is 'Set Suite variable'
See: http://robotframework.googlecode.com/svn/tags/robotframework-2.1/doc/libraries/BuiltIn.html#Set Suite Variable
or even 'Set Global variable'.
See: http://robotframework.googlecode.com/svn/tags/robotframework-2.1/doc/libraries/BuiltIn.html#Set Global Variable