![](/img/trans.png)
[英]How can I verify the state of a WPF checkbox during a UI Automation Unit Test using the Windows Application Driver?
[英]How do I test an excel spreadsheet with WIndows Application driver
我已经运行Windows应用程序驱动程序“计算器测试”示例应用程序。 现在,我想用excel电子表格替换Windows标准计算器。
我想将值插入电子表格并检索结果。
我已经查看了Github上的源代码,但无法识别对Calculator App的调用,也不知道对Excel exe的相关调用是什么。
我需要找出如何启动Excel,将值插入excel,然后从Excel电子表格中的预设单元格检索值的方法。
谢谢
嗯,我决定手动测试excel电子表格。 我可以手动快速完成某件事,这变得越来越复杂。 感谢你的帮助。
例:
private Microsoft.Office.Interop.Excel.Application ObjExcel;
private Microsoft.Office.Interop.Excel.Workbook ObjWorkBook;
private Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;
string fileName = System.Windows.Forms.Application.StartupPath + "\\" + textBox1.Text + ".xlsx";
MessageBox.Show(fileName);
try
{
ObjExcel = new Microsoft.Office.Interop.Excel.Application();
ObjWorkBook = ObjExcel.Workbooks.Add(System.Reflection.Missing.Value);
ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBook.Sheets[1];
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = dataGridView1.Rows[i];
for (int j = 0; j < row.Cells.Count; j++)
{ObjExcel.Cells[1, 1]="id";
ObjExcel.Cells[1, 1]="column";
ObjExcel.Cells[1, 2]="column";
ObjExcel.Cells[1, 3]="column";
ObjExcel.Cells[i + 1, j + 1] = row.Cells[j].Value;
}
}
ObjWorkBook.Save();
}
catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); }
ObjWorkBook.Close(null, System.Windows.Forms.Application.StartupPath + "\\" + textBox1.Text + ".xlsx", null);
ObjExcel.Quit();
ObjWorkBook = null;
ObjWorkSheet = null;
ObjExcel = null;
GC.Collect();
this.Text = this.Text + " - " + textBox1.Text + ".xlsx";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.