Forum Discussion
> 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?
I have tried both. Also I put wait after the operation but problem not resolved.
- AlexKaras6 years agoChampion Level 3
Hi,
> Touch() method requires the x,y co-ordinates
Only if you need to touch at a certain point. Otherwise coordinates may be omitted and the touch will be done in the center of the object. See documentation for detailed description.
> I am finding my web objects from xpath
This may matter. Really. Search by XPath is not recommended in TestComplete's world and should be used as a last resort only. Native TestComplete search functionality (Aliases, .FindXXX(), etc.) must be used wherever possible.
The case is that when TestComplete searches by XPath, the search is done by DOM means and the result is native DOM element (or null). If the XPath search finds some element, TestComplete tries to match it to the object from the Object Browser.
If TestComplete can find the matching object, then TestComplete wraps the native DOM object with its wrappers and return wrapped object as a result of the search. The returned object contains all methods and properties that are common for any onscreen object in TestComplete (like .Exists, .Keys(), etc.) or are specific to the given object (e.g. .TouchItem() method for some mobile lists).
If the matched object cannot be found in the Object Browser, then found native DOM object is returned as a result of the search. Obviously, this object does not contain any method or property provided by TestComplete and contains only native methods and properties provided by DOM. And only they can be used from test code.
So, the first thing I would suggest to do is to go away from XPath search and replace it with the one provided by TestComplete.
You can use the following code to figure out if TestComplete or native DOM object was returned as a result of search by XPath:
if (aqObject.IsSupported(<FoundObject>, 'Exists'))
' TestComplete object was returned. Any TestComplete method/property can be used
else
' Native DOM object was returned. Only DOM methods/properties can be used
- AlexKaras6 years agoChampion Level 3
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?
- smartbearrj6 years agoContributor
Hi AlexKaras,
> Is the text still entered into some other field or something else happens?
Nothing happens when script statement for obj.SetText(string) or obj.Keys(string) is encountered .It just takes some time to go to next statement.
>For mobile controls .Touch() method exists as well. As per documentation, it is similair to .Click(), but you may try it as well.
I have not tried obj.Touch() till now since I thought to overcome this with Keys or SetText() etc and also since Touch() method requires the x,y co-ordinates too. I will try this one as a temperory solution and hope this is going to work as I have tried this once as Mobile.Device("Device Name").Touch(X,Y) and it worked.
One more thing to let you know that Mobile.Device("Device Name").Keys(string) works but that does not solves my problem since this inputs the string starting from the current cursor position.SO if I do this then all the texts are going to be entered in the same field since my cursor is not switching to the other field even after finding the next web object successfully.
>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.
On-screen virtual keyboard is not opened to note.
>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?
One this I had noted that , while i was stepping-in the script with F11 , and checking the object browser , some times I had to refresh my object browser then only it was updating the element.
One more thing to note here , I am finding my web objects from xpath which requires the web page opened and probably will not require the object browser to be updated except at least the web page, so ,even though objects are there but objects are not shown in the object browser until I refresh it, Keys and SetText methods may be failing for this reason since object is not in the object browser and the methods willl also not be available?
Also I was going through the object browser and checking evet element in the three ,elements are not properly shown.e.g. my username, password and signin button object are shown in the object browser tree but when i click on them they are not shown in the object preview.
Also when I try to focus in the device screen ,individual elemenets are not focused rather it takes any radom rectangle over the screen.
Please suggest.
- smartbearrj6 years agoContributor
Hi AlexKaras
> Only if you need to touch at a certain point. Otherwise coordinates may be omitted and the touch will be done in the center of the object. See documentation for detailed description.
I will try this one.
Thanks.
- smartbearrj6 years agoContributor
I did try this one. I can see the Touch() method in the list of methods available for the object, yet touch is not being simulated on the mobile Test device.
Also I used co-ordinates for touch on object which opened the virtual keyboad on the android device but when I did use Keys(string) on object after this keyboard was closed and string was not entered in the text field.
Related Content
- 17 days ago
- 10 years ago