C# 使用automationelement
我想测试用windows窗体组成的windows应用程序。我决定和图书馆的自动化设备一起工作 问题是我不知道如何使用它。例如:如何在使用automationelement处理的文本框中进行书写 代码如下:C# 使用automationelement,c#,unit-testing,windows-forms-designer,automationelement,C#,Unit Testing,Windows Forms Designer,Automationelement,我想测试用windows窗体组成的windows应用程序。我决定和图书馆的自动化设备一起工作 问题是我不知道如何使用它。例如:如何在使用automationelement处理的文本框中进行书写 代码如下: var processStartInfo = new ProcessStartInfo(SATELITE_PATH); var pSatelite = Process.Start(processStartInfo); pSatelite.Wait
var processStartInfo = new ProcessStartInfo(SATELITE_PATH);
var pSatelite = Process.Start(processStartInfo);
pSatelite.WaitForInputIdle();
Delay(2);
satelite = AutomationElement.RootElement.FindChildByProcessId(pSatelite.Id);
AutomationElement loginUser = satelite.FindDescendentByIdPath(new[] {"frmLogin", "txtUserName"});
我想在loginUser中写入用户。我怎么做
真的谢谢 使用:
var processStartInfo = new ProcessStartInfo(SATELITE_PATH);
var pSatelite = Process.Start(processStartInfo);
pSatelite.WaitForInputIdle();
Delay(2);
satelite = AutomationElement.RootElement.FindChildByProcessId(pSatelite.Id);
AutomationElement loginUser = satelite.FindDescendentByIdPath(new[] {"frmLogin", "txtUserName"});
if (loginUser != null)
{
ValuePattern valPattern = loginUser.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valPattern.SetValue(username);
}