Question
"A control has already been created and enqueued"
I am using SetNextKey(key) in a C# component right before the automation clicks a link on a web page, which adds additional form fields. The OpenSpan interrogated controls use clones and key properties. I am using Visual Studio 2015 with Pega plugin v.8.0.1081.
The automation flows successfully during two additions, but during the third round of additions, the above method causes an error:
"A control has already been created and enqueued"
I am a little stumped as to how to troubleshoot this. I have checked the value of the keys during all the additions, and everything seems kosher. Furthermore, it only errors on 1 textbox control out of 4 controls being set, and the call is wrapped like the following.
/* the "key" variable gets passed into the method, as does the parentCtrl */
foreach (WebControl ctrl in parentCtrl.Controls)
{
if ((ctrl.UseKeys)&&(!ctrl.IsKeyAssigned(key)))
{
ctrl.SetNextKey(key);
}
}
Any insights how to troubleshoot the exact cause of the control already being "created and enqueued" would be greatly appreciated.
Assuming that message means what I think it does (that you have already called SetNextKey for that key value), then that would lead me to believe your logic isn't taking into account the "queue" or your counter creating the keys is off somehow. I would add some logging around this area whenever you call SetNextKey to log what the value you are setting is. I'd also log when the control is created and what its key is. By comparing these two, you can see if you are somehow jumping the queue.