Skip to main content
Participant
November 10, 2011
Answered

Programmatic tab through the components on the screen

  • November 10, 2011
  • 1 reply
  • 76843 views

Hello,

I've a requirement to tab through all the components that are in the tab order in a screen. But it has to be done programmatically on press of a button, if a user presses tab key on the keyboard, tabbing follows an order as set on the tabIndex property of each and every component. can this be mocked by a button press? if so how can I it be done?

This topic has been closed for replies.
Correct answer Alex J Harui

I think you will need to dispatch KEY_FOCUS_CHANGE event.

1 reply

Participant
November 10, 2011

If I understand the question correctly, you want to mock the behaviour of the "TAB" key when your application is opened by the "click" event of a button component.

The application should cycle the focus between spark components on the KeyboardEvent with the Keyboard.TAB for the keyCode property.

I believe you can simulate this by manually constructing this KeyboardEvent in the handler function of your button's click event. The event should propagate and trigger the default behavior of the TAB key.

Participant
November 10, 2011

Let me put this way, I want to remove the button, What I'm trying to do is to test the Accessibliity of hte application using the Selenium, Selenium communicates with the UI some how, I'd like to have some comands on the selenium side which can help me to Tab through the application.

Participant
November 10, 2011

Sorry but I'm unable to help you with Selenium directly, you might have better luck by posting the question on its forums.

However, I do have one idea. It seems like selenium has some support for simulating keyboard events.

Look for the functions keyDown ( locator,keySequence ), keyPress ( locator,keySequence ) and keyUp ( locator,keySequence ) here http://release.seleniumhq.org/selenium-core/1.0/reference.html#actions

Of course, seleniums simulated-key support has some limitations for different operating systems, as evident from this post:

http://code.google.com/p/selenium/issues/detail?id=368

In any case, I would try to simulate the tab event directly in your Selenium client.