Ask a Question

aqObject.SetPropertyValue Not able to set value for Keys or Text

Logiv
Contributor

aqObject.SetPropertyValue Not able to set value for Keys or Text

Hello,

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.

10 REPLIES 10
Marsha_R
Community Hero

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

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.

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
ApplePen
Contributor

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

As  

Logiv
Contributor

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

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.

Logiv
Contributor

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

Thank you. I don't have that property either.

I might need to resolve into clicking! Thanks to both of you.

Marsha_R
Community Hero

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

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.

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
Logiv
Contributor

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

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.

Marsha_R
Community Hero

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

Keys will take a string

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-sys-deskto...

 

If your variable is not a string, you can convert it inline as you are passing it to Keys.  There are examples here:

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/datetimetoformat...

 

Here are other ways to convert from type to type:

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/index.html

 

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sonya_m
Community Manager

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

Thanks everyone for your help!

 

@Logiv were the articles Marsha provided useful for your case?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Logiv
Contributor

Re: aqObject.SetPropertyValue Not able to set value for Keys or Text

Hello!

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..

cancel
Showing results for 
Search instead for 
Did you mean: