Ask a Question

Keys method does not input the entire string

SOLVED
jaredjamieson
Occasional Contributor

Keys method does not input the entire string

I am able to use the method:

 

    on_screen_element.keys("1234567890");

 

Most of the time, with smaller strings, this correctly simulates pressing each key in the string.  With strings that are generally 'longer' such as the example, the output ends up being:

 

    134567890

 

This ends up completely missing the 2nd element of the string consistently.  When checking the logs, it states:

 

    The keystrokes '1234567890' were sent to the control.

 

I have attempted to resolve this issue by doing:

 

    for (letter in string)

        on_screen_element.keys(letter);

 

This results in the same issue.  Any help would be greatly appreciated!  Thank you all in advance.  

 

9 REPLIES 9
Marsha_R
Community Hero

I've never seen a problem with Keys before, even with very long strings.

 

If you aren't on the latest version of TestComplete, I would try updating and see if that fixes it.

 

If you are on the latest version already, I would contact Support directly about this. Here's the link:

https://support.smartbear.com/testcomplete/message/


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
tvklovesu
Frequent Contributor

Just wondering, can't you use SetText() instead of Keys(). SetText works seamlessly. 


@tvklovesu wrote:

Just wondering, can't you use SetText() instead of Keys(). SetText works seamlessly. 


lol I have found it to be the exact opposite - SetText doesn't work where I need it and Keys always does


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
jaredjamieson
Occasional Contributor

That is what I have noticed. I cannot use SetText() on the same objects I can use Keys().

Keys is meant to mimic a person typing so I would expect it to work anywhere. SetText is changing a property internally and the code under test may not react well with that, for instance the UI would not know that there was a new value in a field so even though you set the value you could not see it.

 

What version of TC are you using? Did this work for you before your last update or is this something new you are trying?

 

 


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
jaredjamieson
Occasional Contributor

No worries using the SetText() method since I don't even have the option to use it.  

 

My TestComplete Version is version 15.44.11.7 x64.  The most recent release of TestComplete is 15.47.  Within these newer releases, the only thing for the Mobile module that looks to affect my issue is that there were improvements in the performance of the Keys module.  Do you think this could be a resolution?

 

Here are some other versions that may be a related to my issue:

License for Perpetual (Desktop, Web, Mobile).

Microsoft Windows 10 Enterprise, 64-bit (10.0 Build 19044)

I would go ahead and try the upgrade.


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
jaredjamieson
Occasional Contributor

.Keys() appears to have been working now.  I did not go through with the update as mentioned above.  As I have not changed anything, I assume I was just having a random bug that is no longer in affect.  I'll accept the update as the solution since that would make the most sense if this inconsistency was still present.  

I finally found why SetText() is not available few times and its available at other times. If the object you are using has element tag as input then you will see the setText() and if that objects tag is something like span, div or anything else other than input then you can't use setText() and in that case we left with only option to use Keys method.

cancel
Showing results for 
Search instead for 
Did you mean: