private void btnStartGUITest_Click(object sender, System.EventArgs e) { TypesToVerify = new TypeVerificationSerializable(); GUISequence = 0; //added for chapter 8 GUITestSeqList = new GUITestUtility.GUIInfoSerializable(); opnAUT.Title = "Specify an Application Under Test"; opnAUT.Filter = "GUI Applications(*.EXE; *.DLL)|*.EXE;*.DLL|All files (*.*)|*.*"; if (opnAUT.ShowDialog() == DialogResult.OK) { applicationUT = opnAUT.FileName; GUITestSeqList.AUTPath = applicationUT; GetTypeToTestFromAUT(); try { formUT = (Form)GUITestUtility.StartAUT(applicationUT, startupForm); } catch (InvalidCastException ex) { //Chapter 13 //MessageBox.Show(ex.Message); formUT = GUITestUtility.StartControlUT(applicationUT, startupForm); formUT.Show(); } } else { return; } }
private void StartAUT() { seqGUIUT = new GUITestUtility.GUIInfoSerializable(); object obj = (object)seqGUIUT; GUITestUtility.DeSerializeInfo(guiTestDataStore, ref obj); seqGUIUT = (GUITestUtility.GUIInfoSerializable)obj; string AUTPath = seqGUIUT.AUTPath; string startupType = seqGUIUT.AUTStartupForm; int hwnd = 0; if (AUT == null) { try //chapter 13 { AUT = (Form)GUITestUtility.StartAUT(AUTPath, startupType); hwnd = (int)AUT.Handle; } catch (InvalidCastException ex) //chapter 13 { AUT = GUITestUtility.StartControlUT(AUTPath, startupType); AUT.Show(); Control ctrlAUT = AUT.Controls[0]; hwnd = (int)ctrlAUT.Handle; } } //int hwnd = (int)AUT.Handle; StringBuilder sbClsName = new StringBuilder(128); GUITestActions.GetClassName(hwnd, sbClsName, 128); string clsName = sbClsName.ToString(); string winText = AUT.Text; string pText = ""; GUITestActions.SynchronizeWindow(ref hwnd, ref winText, ref clsName, ref pText); }