Search code examples
seleniumrobotframework

Press enter key using 'Press Key' keyword


I am using Robot Framework and am trying to simulate a carriage return/key press of the enter key within a a text field. The functionality behind this element is once a page number has been entered into thie text field and the enter key pressed the viewer will navigate to that given page.

I have tried ascii codes to no avail:

Press Key  css=div[id='viewer-toolbar-pagination']  \\13
Press Key  css=div[id='viewer-toolbar-pagination']  \\10
Press Key  css=div[id='viewer-toolbar-pagination']  \\176

I have sent other ascii codes to the same element e.g. \32 (space) and that worked fine.

Any help appreciated.


Solution

  • To press Enter in RobotFramework selenium the code is

    Press Keys    locator_here    ENTER
    

    And Space is

    Press Keys    locator_here    SPACE
    

    Atleast Tab works like this, I haven't tested others, but I think this will help a little bit (even tho I'm 3 years late)