3
votes

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
Why must you hit tab for? cant you just input the text to the field ? Like normal? - Goralight
it is not working - user7982813
Right - Well if you need tab - use this. press key | <locator...> | \\09. If you then want to hit Enter key - replace the \\09 with \\13. Read more about it here robotframework.org/Selenium2Library/… - Goralight

5 Answers

3
votes

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.

2
votes

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

After installing, try the below lines for tab:

Keydown. tab

Keyup tab

1
votes

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

1
votes

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

0
votes

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.