Ask a Question

Desktop Driver Key Board operations dont seem to work with swing.

SOLVED
davemcauley
New Contributor

Desktop Driver Key Board operations dont seem to work with swing.

Desktop Driver Key Board operations dont seem to work with swing.

 

Trying driver.getDesktop().keys("[Tab]") operation while in a text box but nothing happens.

5 REPLIES 5
AlexKaras
Community Hero

Hi,

 

Might it be because 'Tab' is processed by the desktop but not the tested application?

(In my case, the Start button becomes selected when I manually click somewhere on the desktop and press Tab key.)

 

Regards,
  /Alex [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
================================

Hi Alex.

 

driver.getDesktop().keys("[Tab]") doesn't work at all in the java code regardless of swing or not.

 

In other words the tab operation is not perfromed by driver.getDesktop().keys("[Tab]"), it does nothing.

 

https://support.smartbear.com/testleft/docs/using/creating-tests/simulating-user-actions/keystrokes....

 

Regard.

David.

Hi David,

 

the tab operation is not perfromed

And what are your expectations from execution of the

driver.getDesktop().keys("[Tab]")

code line?

(Note, that most probably (as I do not know your code), the focus moves to some other window and thus I am not sure that you can observe the result of this code line execution.)

 

Update:

I am not using Java, so I tried your code with C#.

When running under debugger I also did not see any evidence of code execution. But when I started code without debugger, I clearly saw that Tab was processed by the application's window:

AlexKaras_0-1628524750714.png

 

 

 

Regards,
  /Alex [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
================================

Hi Alex.

I understand what you are saying.

 

But how then can you tab to different parts with in your application if that is what is required?

If you tab with in any known windows application it will tab to objects with in that application only.

 

So what is the purpose of this code "driver.getDesktop().keys("[Tab]")"  if it cant be used to tab around your application?

 

Thanks.

David.

 

Hi David,

 

how then can you tab to different parts with in your application if that is what is required?

Not sure if I got your question right...

I have much more experience with TestComplete but not with TestLeft, but, considering that TestLeft is based on TestComplete's engine, I believe that the described functionality will match.

So, when you write test code, you usually know what window/object you need to interact with and usually the code looks like driver.Window(...).Control(...).Keys(...).

If some window must be activated (i.e. put into foreground), then its .Activate() method should be used.

.Keys() method basically puts specified string into the message queue of referenced window/control. How the queue is dispatched and processed is determined by the OS and the application itself.

For example, the input put into the window message queue can be dispatched first to the active focused control and then, if not processed, to the window itself.

 

To summarize: explicit reference to windows/controls improves reliability of test code. Sending keys to desktop (or, say, main application's window) might work but with much less reliability and the result of the execution will depend on the current system's state. (For example, unexpected notification window might break the whole test.)

 

Does this answer your question somehow?

 

Regards,
  /Alex [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
================================
cancel
Showing results for 
Search instead for 
Did you mean: