Page 1 of 1
How do I use a windows form to start off a set of test cases
Posted: Fri Jun 13, 2014 8:57 pm
by Grogimer
I am going to apologize in advance as i am a novice and had horrible luck searching for the answer. Basically, i am trying to get form to pop up and request an email address before running a specific subset of tests.
What i have done thus far:
- Using C#
Added Windows Application Form in Ranorex
Setup the form called OSTest
Added a code module to use the form, code to show the form below
Code: Select all
public void StartForm()
{
OSTest startForm = new OSTest();
startForm.Show();
}
So the problems i am having:
- The test case continues after showing the form and does not pause for interaction.
The form comes up incomplete. See before and after images below.
At Run Time:
At Design TIme:
Thanks in advance for taking a look.
Re: How do I use a windows form to start off a set of test cases
Posted: Thu Jun 19, 2014 8:36 pm
by Grogimer
Ok, I would say there is probably a better/cleaner way to do this but i got it to work. Running the form on a separate thread and setting a do while loop to look for a change in a parameter.
This is the user code in the recording:
Code: Select all
[language=csharp]
public partial class Setup
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
///
private void Init()
{
// Your recording specific initialization code goes here.
TestSuite.Current.GetTestCase("OSTest").Parameters["continueExecution"]= "False";
}
[STAThread]
public void StartForm()
{
OSTest startForm = new OSTest();
Thread thread = new Thread(ApplicationRunProc);
thread.Start(startForm);
}
public void waitForWindow()
{
do
{
}while(TestSuite.Current.GetTestCase("OSTest").Parameters["continueExecution"] == "False");
}
private static void ApplicationRunProc(object state)
{
WinForms.Application.Run(state as WinForms.Form);
}
}
[/language]
This is the code in the windows form:
Code: Select all
[language=csharp]
public partial class OSTest : Form
{
public OSTest()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void BtnContinueClick(object sender, EventArgs e)
{
TestSuite.Current.GetTestCase("OSTest").Parameters["continueExecution"] = "True";
TestSuite.Current.GetTestCase("OSTest").Parameters["userName"] =this.tbUserName.Text;
TestSuite.Current.GetTestCase("OSTest").Parameters["password"] = this.tbPassword.Text;
TestSuite.Current.GetTestCase("OSTest").Parameters["emailAddress"]=this.tbEmailAddress.Text;
if (this.rbBitRaider.Checked)
{
TestSuite.Current.GetTestCase("OSTest").Parameters["sysTest"]= "BitRaider";
}
else if (this.rbSSN.Checked)
{
TestSuite.Current.GetTestCase("OSTest").Parameters["sysTest"]= "SSN";
}
else
{
TestSuite.Current.GetTestCase("OSTest").Parameters["sysTest"]= "Both";
}
this.Close();
}
}
[/language]