I have a date field which I am trying to input with today's date. The particular field does not have the Text property but it does have the Keys property.
I am trying to make sense of how they work but I don't fully understand how it works - or maybe the limitations are in my software and not TC. I have currently insert the proper date format in the variable "FormatedDate".
I have Field A that has both Text and Keys properties
and Field B (which is the one I need) with only Keys property.
I can enter the date in field A using:
aqObject.SetPropertyValue(Sys.Process("Maint").VCLObject("MainForm").Window("MDIClient", "", 1).VCLObject("PLUForm").VCLObject("BackPanel").VCLObject("Panel10").VCLObject("Edit2"),"Text",FormatedDate)
But when I try to do the same using Keys (or even without the date, I try to type 123) and nothing happens (no error, no output):
aqObject.SetPropertyValue(Sys.Process("Maint").VCLObject("MainForm").Window("MDIClient", "", 1).VCLObject("PLUForm").VCLObject("BackPanel").VCLObject("Panel10").VCLObject("Edit2"),"Keys","123")
So I can achieve the desired result on fields that have the Text property, but on the fields that have the Keys property I am unable to get any data in those fields. There are no other obvious fields to use (no wtext, no caption, etc). I seem to only have Keys available.
The quickest way to see what works is to record a short test where you type in that box and see what code TC gives you in the test it creates.
As Marsha_R said. You can record the code as reference.
Some date object has the 'wDate' property. You will use it like Object.wDate = '02/20/2021' if it has.
Yes that is what I tried at first.
When recorded, the test does a click in the field, then enters the value. This works, but I wanted to avoid the clicking the field in case it changes to a different position (also timing issues and things like that sometimes don't make the cursor/clicking reliable).
When recorded and converted to script, it doesn't use the aqObject.SetPropertyValue.
I thought that by setting the property that way, I could avoid the clicking in the specific field.
Thank you. I don't have that property either.
I might need to resolve into clicking! Thanks to both of you.
Since you are using object properties to click the field, it will not matter if the field moves. That's only an issue if you are using coordinates instead of the properties.
Timing issues may indeed come up but those are common and can be addressed with some version of Wait. If that happens to you, start another post and we can help you fix that.
The other downside of using Keys seems to be that I cannot pass a variable. I wanted to insert today's date in the field but it is going to be a lot more work to make it work with keys - if even possible! As of now, it is failing.
Keys will take a string
If your variable is not a string, you can convert it inline as you are passing it to Keys. There are examples here:
Here are other ways to convert from type to type:
Thanks everyone for your help!
@Logiv were the articles Marsha provided useful for your case?
I did not have time to continue working on this.
The clicking in a problem for me because the whole grid is a single component. The object spy cannot focus on a single field, I get the whole grid.
So until I resolve that, it's going to be a little complex. The programmers won't change the code because I'm only QA, it's not a problem reported by a customer..
The field I was has it's own component, but it's only available once I have clicked in that field (and wait a few ms).
I will try to find a way around this and test the suggestions but I won't have time this week.
Although, if I don't resize or move the window, my click works. I was able to enter my date in a string variable and that did not pass to keys, I had tried already. Maybe the links will show me something different than what I tried..