Robot Framework using Python, key press without selecting any button or element in the page

keypress, python-2.7, robotframework

Solution

Linux Alternative can be PyAutoGUI

Although it works for Windows and MacOS(cross-platform) also, as described in the docs

PyAutoGUI works on Python 2 & 3. Install from PyPI with `pip install pyautogui`

Examples:

import pyautogui

def send_keys():
    """
    Works on Windows/Mac/Linux
    """
    pyautogui.press('enter') #Presses enter
    pyautogui.hotkey('ctrl', 'shift', 'esc') #Performs ctrl+shift+esc
    pyautogui.typewrite('Hello world!\n', interval=secs_between_keys)  #Useful for entering text, newline is Enter
    pyautogui.typewrite(['a', 'b', 'c', 'left', 'backspace', 'enter', 'f1'], interval=.4) #A list of key names can be passed too

Problem

I am automating one application using Robot Framework using Python. In a certain situation I need to press Enter without selecting any button or element of the page once the page is loaded. I have tried with the below example (using `Press Key`), but it didn't work as I don't want to select any specific button or element of the page before press Enter on the page. Examples: ``` Press Key text_field q Press Key login_button \\\13 # ASCII code for the Enter key ``` The below keyword is not recognized by the IDE, most probably because of version: ``` Press Key Native ``` Is there a solution to get rid of this problem?

Original source