/// <summary> /// 导出测试数据模板 /// </summary> private void ExportTestDataTemplate() { if (scriptModel != null) { var testDataTemplate = new TestDataTemplate(); FormTemplate currentForm = null; foreach (var command in scriptModel.GetCommandList()) { if (!String.IsNullOrEmpty(command.FormMark)) { if (command.IsStartFormMark()) { testDataTemplate.AddFormTemplate(command.GetFormName()); currentForm = testDataTemplate.FindFormTemplate(command.GetFormName()); } else if (command.IsEndFormMark()) { currentForm = null; } } if (currentForm != null && command.IsFormFieldMark()) { currentForm.AddField(command.ValueVarName); } if (command.IsAssertMark()) { testDataTemplate.AddAssertTemplate(command.AssertName, command.GetAssertVarName()); } } SaveTestDataTemplateToExcel(testDataTemplate, saveFileDialog1.FileName); } }
/// <summary> /// 加载测试数据 /// </summary> /// <param name="testScriptFileName"></param> private void LoadTestScript(string testScriptFileName) { string scriptString = ""; using (System.IO.StreamReader sr = System.IO.File.OpenText(testScriptFileName)) { scriptString = sr.ReadToEnd(); } ITestScriptParser parser = new AutoTestFramework.SeleniumTestEngine.SeleniumIdeHtmlScriptParser(); scriptModel = parser.Parse(scriptString); textBox3.Text = scriptModel.StartUrl; textBox4.Text = scriptModel.Title; dataGridView1.DataSource = new List <TestCommand>(scriptModel.GetCommandList()); }