Forum Discussion
> I am finding in my log obj.SetFocus() is not a function.
.SetFocus() exists not for all controls.
Check in the Object Browser if it exists for the given control.
P.S.
Some more universal code might be like this:
if (aqObject.IsSupported(<object>, 'SetFocus'))
<object>.SetFocus();
else
<object>.Click();
No Its is not havng SetFocus( ) method.
Also one more thing whcih i am seeing in my object browser -
However I can find the controls in the object browser with all its properties and methods , I can not see the control in the object preview .And I think this is the reason why keys are not sent ot the control!
I have attached the Screen shot below.
- AlexKaras7 years ago
Champion Level 2
> I think this is the reason why keys are not sent ot the control!
While it is strange that nothing is shown in the object preview and you may ask Support difectly about this via the https://support.smartbear.com/message/?prod=TestComplete form, I do not think that this is the reason for the input problem.
Have you tried to .Click() this textbox? Does this resolved the problem with the input text? Can you see Click and/or SetFocus methods on the Methods pane of the Object Browser?- Marsha_R7 years ago
Champion Level 3
You can try recording a keyword test that does what you want and see what TC creates from that. You can then convert that to a script to get even closer to what you need.
- smartbearrj7 years agoContributor
I can see the SetText operation in the keyword test but when I run the recorded keyword test , text is not entered again in the text boxes. Also recorded the script and I see the SetText method there as well, but again running the recorded test does not enter the text i pass.
- smartbearrj7 years agoContributor
I have tried both. Also I put wait after the operation but problem not resolved.
- AlexKaras7 years ago
Champion Level 2
Hi,
> I have tried both. [...] problem not resolved.
That's strange...
Is the text still entered into some other field or something else happens?
For mobile controls .Touch() method exists as well. As per documentation, it is similair to .Click(), but you may try it as well.
I do not recommend to use .SetText() method in favor of .Keys() one.
What is displayed on the mobile screen if you set a breakpoint on the line with .Keys() call and run the code? I would expect that control is focused and on-screen virtual keyboard is displayed so that you can type text.
May it be that some previous actions require some time to complete and the problematic control cannot accept input until they are completed? Maybe you need to wait for some time before touching the input control?