Husain Ashraf
Husain Ashraf

Reputation: 251

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.

Upvotes: 6

Views: 41758

Answers (2)

Sharvik Patel
Sharvik Patel

Reputation: 31

To press enter

Press Keys   locater_here   ENTER
Press Keys   locater_here   RETURN

To press Space

Press Keys   locater_here   SPACE

To fetch the link

Press Keys   <Link Xpath>   ENTER

If not working then update your selenium library into the Robot Framework

pip install robotframework-seleniumlibrary    | latest version - 6.0.0

Upvotes: 0

Joni
Joni

Reputation: 116

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)

Upvotes: 9

Related Questions