I have several workflows in UIPath. What I'm wanting to do is: for a given flowchart, I want to execute those workflows in "random" order - but also not execute the same workflow twice.
For example let's say I have 3 workflows. I put them all in the same flowchart.
When I click 'Run', I want UIPath to decide which one to run first, but after that one runs, I want it to decide between Workflow 2 and Workflow 3 - and not run Workflow 1 again.
Logically I don't know how to do this. I'm fairly new to UIPath so I don't hae a lot of experience with variables, but I'm thinking the one approach might be to create a Boolean variable for each workflow and then after each one runs, I toggle the variable for that workflow. However, I don't know how to do that...
An alternative approach I can think of is to use a Switch (or multiple Switches) and set the expression to a random number between 1 and 3 using new Random().Next(1,3) - but then I still have the problem that it might run Workflow 1 twice. Is there a way to tell the Switch activity to execute all Cases in a random order?
Here's one possible approach. Make sure each workflow is moved to its own file. Create a collection with all file names. Shuffle the list, iterate over it, and then invoke the workflow file.
My example uses Integers, but you can use Strings alike. Note that I initialized the list in the Invoke Code activity, but you can do that anywhere you like and pass the list as an In Argument.
Here's the code used in the Invoke Code activity, taken from here:
Dim r As Random = New Random()
Dim list As New List(Of Int32)(New Int32() {1, 2, 3})
out_List = list.OrderBy(Function(a) r.Next()).ToList()
One benefit of this approach is that adding or removing workflow files simply requires changing the list, but no changes to the main workflow itself.
Related
I am trying to merge more than 10 dta files with same unique identifier id in Stata. I have tried using the following code, but it shows error _merge already defined r(110). I think it is due to creation of variable _merge after the first two file merges. Is there a better work around for this and get all files merged at once?
local files : dir "E:\Research\stata12" files "*.dta"
foreach file in `files' {
merge 1:1 id using `file'
}
See help merge for the background. By default, merge creates the new variable _merge as a report on the success (or failure) of the command (NB not function; in Stata function is not a synonym for command).
It follows that
EITHER
You need to specify a different variable name with the generate() option.
OR
You need to drop or rename the _merge variable otherwise.
In either case, it is a very good idea to look carefully at _merge at each stage to see if results are as you expect. tabulate _merge followed if necessary by a list or edit is usually sufficient.
Further, forcing a series of merges is efficient coding if and only if you are certain that the merges will be unproblematic. I tend to merge one by one, slowly but surely.
I have a feature file A with 8-9 lines of steps which is covering one scenario. Now I need to use feature file A as a background step in feature file B by reducing number of steps to 3-4.
My approach:
In feature file B - Reduce steps(from feature file A) to 3-4 lines, use helper methods and add as background steps.
Feature file A:
Feature: I want to create an event
Background: User is Logged In
Given a logged in user
Scenario: Creating an event
Given I select event
And I add event details
And I add start and end time
Then Timings will be added successfully
When I add ticket information and continue
And Publish my event
Then I verify event will be created successfully
Feature file B
Feature: Place an order
Background: Event is created
Given a logged in user
When I select event and fill in required details
Then event should be published
I'm concern about duplication. I'm using feature file A as a background step in feature file B by reducing number of steps but functionally both feature files are testing same feature.
Please suggest a better approach if possible. Thank you
So fundamentally using helper methods to reduce number of steps is only something you should do if the compressed steps are also conveying the information correctly. So here is an example (You don't need helpers here either), that would be a good use case.
Given I have a party of 2/1/0 # This means adults/children/infants
And the child is under 12
And I am flexible on my flights
And I am going to Spain
When I search for flights
Given I have Spanish flights displayed # You could also add the pax in here if you wanted
Now if you're wanting to use helper methods, that is also fine, but you need to remember cucumber is primarily a tool for encouraging collaboration as well as providing documentation, testing and specification in the same place. So once you try to DRY up your lines, think about whether actually you just want to "compress" the lines down.
i.e.
Given('I am {int} years old') do |age|
#person.age = age
end
Given('my name is {word}') |name|
#person.name = name
end
Given('my hometown is {string}') |hometown|
#person.location = hometown
end
Can become
Given('I am {word}, {int} years old from {string}') |name, age, hometown|
#person.name = name
#person.age = age
#person.location = hometown
end
Hopefully some of these tips will have given you some thought.
Using SSDT 16.0.61908, SSIS 15.0.2000 and VS Community 16.3.4
I have a package that contains two data flows. I want to use a package-scope variable defined by the user or passed in through a preceding process to determine which data flow to execute.
For example, if the variable indicates "A" then execute data flow 1. If the variable indicates "B" then execute data flow 2.
I'm sure there has to be a simple way to do this but I'm not seeing it in any of the documentation clearly.
Pass in a parameter to the package with either "A" or "B" in your example.
Use a task that doesn't really do anything like an expression.
link the expression to both data flows and condition the path to either A or B.
You're looking for a precedence constraint. Add a Sequence Container to your package. Call it Decision Point or something like that. The purpose of this is to have a shared parent for all the executables that need to figure out if it's their turn to run
Then drag the green arrows out from it to your various data flows.
Double click the arrows and change the constraint from Constraint to Constraint and Expression.
SSIS sequence container: Setting conditional parameters for when file is not present
In your expression, you'd do something like #[User::MyVar] == "A" for Data flow 1, #[User::MyVar] == "B" for Data flow 2, etc
If you need then have the same successor to both of them, you'll modify the output path of the various data flows to use an Or precedent constraint.
2 Data Flow Tasks Linking to one Execute SQL Task
I'm currently working with JMeter in order to stress test one of our systems before release. Through this, I need to simulate users clicking links on the webpage presented to them. I've decided to extract theese links with an XPath Post-Processor.
Here's my problem:
I have an a XPath expression that looks something like this:
//div[#data-attrib="foo"]//a//#href
However I need to extract a specific child for each thread (user). I want to do something like this:
//div[#data-attrib="foo"]//a[position()=n]//#href
(n being the current index)
My question:
Is there a way to make this query work, so that I'm able to extract a new index of the expression for each thread?
Also, as I mentioned, I'm using JMeter. JMeter creates a variable for each of the resulting nodes, of an XPath query. However it names them as "VarName_n", and doesn't store them as a traditional array. Does anyone know how I can dynamicaly pick one of theese variables, if possible? This would also solve my problem.
Thanks in advance :)
EDIT:
Nested variables are apparently not supported, so in order to dynamically refer to variables that are named "VarName_1", VarName_2" and so forth, this can be used:
${__BeanShell(vars.get("VarName_${n}"))}
Where "n" is an integer. So if n == 1, this will get the value of the variable named "VarName_1".
If the "n" integer changes during a single thread, the ForEach controller is designed specifically for this purpose.
For the first question -- use:
(//div[#data-attrib="foo"]//a)[position()=$n]/#href
where $n must be substituted with a specific integer.
Here we also assume that //div[#data-attrib="foo"] selects a single div element.
Do note that the XPath pseudo-operator // typically result in very slow evaluation (a complete sub-tree is searched) and also in other confusing problems ( this is why the brackets are needed in the above expression).
It is recommended to avoid using // whenever the structure of the document is known and a complete, concrete path can be specified.
As for the second question, it is not clear. Please, provide an example.
I have an application that has 'macro' capabilities. When I map some keys on the keyboard to perform the 'macro', I can also have it launch vbscript instead.
What i'd like to try and do is within my vbscript figure out what keys were used in order to launch the script. Is it posible to do this? Could there be a way in vbscript to figure out what keys were last touched on the keyboard and then I could apply my logic.
The purpose of doing this is to keep the code in a single .vb file instead of several seperate .vb script files(one for each keyboard mapping, possible 3-4). Obviously we are looking to just maintain 1 file instead of multiple files with essentially the same code in each one.
I am leaning towards the idea that this is not possible, but i figured this would be a worthy question for the masses of StackOverflow. Thanks for the help everyone!
What you are asking for is not possible.
Can you change your VBScript to accept parameters and then call it with a different parameter based on which hotkey was selected?
I agree with aphoria, the only way to make something like this possible is if your keyboard mapping software allows you to assign a script/command with parameters/arguments. For example if you used
c:\Temp\something.vbs
then you would change this to
%WINDIR%\system32\wscript.exe c:\temp\something.vbs "Ctrl-Alt-R"
Then in your vbscript code you could collect the argument using the wscript.Arguments object collection to do actions based on what argument/parameter was passed. See the following two links for more info:
http://msdn.microsoft.com/en-us/library/z2b05k8s(VS.85).aspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0915.mspx
The one possible approach you may use is to install keylogger and read its log in your VBScript.
For example save script start time in the very beginning of the script
StartTime = Timer()
and then read one log record of your keylogger before this time.