How to use TAB in Robot Framework

Viewed 15381

I am using Robot Framework for test automation. I have a test case where when the user enters an email address and presses TAB only, and then the next field, NAME, is enabled, otherwise it is disabled. How can I automate this?

5 Answers

Using Selenium2Library of Robot Framework, we can use the Press Keys keyword. It's very easy and has support for a lot of keys including the "command" button for MAC.

Press Keys    locator    TAB

For all supported keys and their names, go to Selenium keys.

You can try the PyAutoGUI library for pressing any key from keyboard.

After installing, try the below lines for tab:

Keydown. tab

Keyup tab

An easy way is to use AutoItLibrary and use keyword Send {TAB}.

From the Selenium2Library documentation:

You can use the Press Key keyword.

Press Key Example

In your case you need to use:

Press Key login_button \09 # ASCII code for TAB key

ASCII code chart

Example from me would be from the SeleniumLibrary keyword Press Keys:

Press Keys  None  TAB

You don't have to use a locator, so in this case the locator=None. In this case it will just send a TAB to your screen.

Related