I have the following code which causes the following exception. I am using this code all over the place and it happens everywhere I have it but not every time.
Here is the error
Unexpected exception occured: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at TacViewLib.LinkSpecific.Surveillance.Air.CreateTrack.CreateTrackRegression.PassiveActiveval()
at TacViewLib.LinkSpecific.Surveillance.Air.CreateTrack.CreateTrackRegression.Start()
at Link_16_Regression.program.J3_2Test(Int32& error)
Here is the code
Code: Select all
public static void Strengthval()
{
repo.FormMainCreate.ListItemStrength.Click();
Keyboard.Press(Keys.Tab);
Keyboard.Press("{LMenu down}{Down}{LMenu up}");
Ranorex.List list2 = "//list[@processname='RealView']";
int AScount = list2.Items.Count;
Random ASvalue = new Random();
AScount = AScount - 1;
int ASnum = ASvalue.Next(1, AScount);
repo.ListRealView.Self.Items[ASnum].Select();
repo.ListRealView.Self.Items[ASnum].Click();
Accessible accElement = new Accessible(repo.FormMainCreate.ListItemStrength);
string StrengthValue = accElement.Value;
ValidateTrack.ValidateTrackRegression.Strength = StrengthValue;
Report.Info("Strength Value Entered = " + StrengthValue);
}