我在 Visual c # express 2010 中使用 UIAutomation 我正在尝试在 UI 应用程序中自动输入文本框文本突然消失在这里是我工作的文件的 UIspy 日志
AutomationElement
General Accessibility
AccessKey: ""
AcceleratorKey: ""
IsKeyboardFocusable: "True"
LabeledBy: "(null)"
HelpText: ""
State
IsEnabled: "True"
HasKeyboardFocus: "False"
Identification
ClassName: "Edit"
ControlType: "ControlType.Edit"
Culture: "(null)"
AutomationId: "100"
LocalizedControlType: "edit"
Name: ""
ProcessId: "5172 (Winpoint)"
RuntimeId: "42 267278"
IsPassword: "False"
IsControlElement: "True"
IsContentElement: "True"
Visibility
BoundingRectangle: "(611, 286, 90, 20)"
ClickablePoint: "(null)"
IsOffscreen: "False"
ControlPatterns
Text
DocumentRange
Text: ""
Length: "0"
Bounding Rectangles: ""
AnimationStyleAttribute: "(not supported)"
BackgroundColorAttribute: "16777215"
BulletStyleAttribute: "(not supported)"
CapStyleAttribute: "None"
CultureAttribute: "(not supported)"
FontNameAttribute: "Microsoft Sans Serif"
FontSizeAttribute: "8"
FontWeightAttribute: "400"
ForegroundColorAttribute: "0"
HorizontalTextAlignmentAttribute: "Left"
IndentationFirstLineAttribute: "(not supported)"
IndentationLeadingAttribute: "(not supported)"
IndentationTrailingAttribute: "(not supported)"
IsHiddenAttribute: "(not supported)"
IsItalicAttribute: "False"
IsReadOnlyAttribute: "False"
IsSubscriptAttribute: "(not supported)"
IsSuperscriptAttribute: "(not supported)"
MarginBottomAttribute: "(not supported)"
MarginLeadingAttribute: "(not supported)"
MarginTopAttribute: "(not supported)"
MarginTrailingAttribute: "(not supported)"
OutlineStylesAttribute: "(not supported)"
OverlineColorAttribute: "(not supported)"
OverlineStyleAttribute: "(not supported)"
StrikethroughColorAttribute: "(not supported)"
StrikethroughStyleAttribute: "None"
TabsAttribute: "(not supported)"
TextFlowDirectionsAttribute: "(not supported)"
UnderlineColorAttribute: "(not supported)"
UnderlineStyleAttribute: "None"
Value
Value: ""
IsReadOnly: "False"
这是我使用的代码,当然我使用自动化 id 100 来定位这个文件
AutomationElement firstname = GetTextElement(appElement, "100");
if (firstname != null)
{
LogMessage("OK " + Environment.NewLine);
LogMessage("typing in the first name...");
{
ValuePattern firstnameval =
firstname.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
firstnameval.SetValue("basem22");
// firstnameval.Text("basem");
// var textbox = AutomationElement(scope, id);
ValuePattern p = firstname.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
p.SetValue("value");
因此,当我运行此代码时,在文本框中输入了“值”,但是如果我更改了 foucs,它就会消失任何想法,我试图自动输入该表单并保存它.. 谢谢