Hello, I have a problem in my dektop application, I would like to retrieve the value of a textBox. This value is contained in an object belonging to the texBox. My component has a formatedtext p...
I based myself on the text property that works well to get around the problem, but I wanted to understand why the formatedtext does not work. In the end the focus of the component already present at the time of the search for the component block this update. Thank you
My component has a formatedtext property that is an object with the following properties inside.
When I try to retrieve the value via the TC Code, it returns empty, as soon as I put a breakpoint at the object and I evaluate the value of the object myself, Value of the component is found. ( oComponent.FormattedText.OleValue)
...
The fact of evaluating the value of this object then allows that I can recover it by letting the code go to the end. I also try to put a delay or make a resfresh of my component but nothing changes, how then do I do?
It's hard to say without seeing your tested app. It sounds like the FormattedText property is only initialized after a certain event occurs in the app, for example, when the object gets an input focus, or when some other property is being read. You need to find out what that event is (ask your developers) and add the corresponding action to your test.
FYI, all native .NET strings have the .OleValue property, so using oComponent.FormattedText.OleValue should be enough. Make sure you are accessing the property of the correct component. Alternatively, check if your object or one of its child objects has the WPFControlText property - it's an extra property added by TestComplete to objects that contain text, such as TextBlock, Section, Paragraph and others.
Maybe try something like this instead?
function GetTextWPF(oComponent) {
var text = "";
if (aqObject.IsSupported(oComponent, "WPFControlText"))
text = oComponent.WPFControlText;
else if (aqObject.IsSupported(oComponent, "FormattedText"))
text = oComponent.FormattedText.OleValue;
else if (aqObject.IsSupported(oComponent, "Text"))
text = oComponent.Text.OleValue;
text = aqString.Trim(text, aqString.stAll);
return text;
}
I based myself on the text property that works well to get around the problem, but I wanted to understand why the formatedtext does not work. In the end the focus of the component already present at the time of the search for the component block this update. Thank you