Press keyboard "Ctrl + A" in Robot IDE (RIDE)

17,734 views
Skip to first unread message

Phuoc Ha

unread,
May 22, 2014, 6:42:38 AM5/22/14
to robotframe...@googlegroups.com
Hi guys,

I'm using Robot IDE to create test case.
I would like to edit a textbox. I have to press key Ctrl + A and enter new value into that textbox.
Anybody know how to create keyword to press key Ctrl + A ?

Please help me.
Thanks all.

Tatu Aalto

unread,
May 22, 2014, 9:38:58 AM5/22/14
to phuo...@gmail.com, robotframework-users

Ugh

I didn't quite get what you are asking, but here is a try.

The keyboard shortcuts are hard coded and can not be changed without a code change. But the desired shortcut may already exist, the list of available shortcuts is in the documentation [1]. Also reading the RIDE How To [2] contains lots of useful information.

-Tatu
Send from my mobile
[1] https://github.com/robotframework/RIDE/wiki/Keyboard-Shortcuts
[2] https://github.com/robotframework/RIDE/wiki/How-To

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

wilco

unread,
May 22, 2014, 9:51:17 AM5/22/14
to aalto...@gmail.com, robotframe...@googlegroups.com, phuo...@gmail.com

I believe they are asking how they can use Robot Framework to send a CTRL+A key sequence to the application under test.

Phuoc, is this correct?  If so, what does your application run in?  A terminal?  A web browser?  A native app?  Depending on how the application is implemented, you will need to use a different library to construct a keyword to send the CTRL+A. 

Phuoc Ha

unread,
May 22, 2014, 11:07:30 PM5/22/14
to robotframe...@googlegroups.com, aalto...@gmail.com, phuo...@gmail.com
Hello Tatu and Wilco,

Now I'm using robotframework-seleniu2Library.
I'm testing on web browser. I want to know how to use keyword from RIDE to press "Ctrl + A" on web browser.
I tried use keyword from selenium2Library like below to press "Enter" key on my web browser with RIDE:
"Press Key             \\13 " #(Selenium2Library.Press Key).
but now I want to find the way how to press key "Ctrl + A".

Thanks to you guys!

Vào 20:51:17 UTC+7 Thứ năm, ngày 22 tháng năm năm 2014, wilco đã viết:

I believe they are asking how they can use Robot Framework to send a CTRL+A key sequence to the application under test.

Phuoc, is this correct?  If so, what does your application run in?  A terminal?  A web browser?  A native app?  Depending on how the application is implemented, you will need to use a different library to construct a keyword to send the CTRL+A. 

On May 22, 2014 9:39 AM, "Tatu Aalto" <aalto...@gmail.com> wrote:

Ugh

I didn't quite get what you are asking, but here is a try.

The keyboard shortcuts are hard coded and can not be changed without a code change. But the desired shortcut may already exist, the list of available shortcuts is in the documentation [1]. Also reading the RIDE How To [2] contains lots of useful information.

-Tatu
Send from my mobile
[1] https://github.com/robotframework/RIDE/wiki/Keyboard-Shortcuts
[2] https://github.com/robotframework/RIDE/wiki/How-To

On 22 May 2014 15:09, "Phuoc Ha" <phuo...@gmail.com> wrote:
Hi guys,

I'm using Robot IDE to create test case.
I would like to edit a textbox. I have to press key Ctrl + A and enter new value into that textbox.
Anybody know how to create keyword to press key Ctrl + A ?

Please help me.
Thanks all.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
Message has been deleted

Phuoc Ha

unread,
May 22, 2014, 11:22:25 PM5/22/14
to robotframe...@googlegroups.com
Hello guys,

This picture can describe what I mean, please help me solve it.

Thanks all.

Vào 17:42:38 UTC+7 Thứ năm, ngày 22 tháng năm năm 2014, Phuoc Ha đã viết:
How to press Ctrl + A.PNG

mr

unread,
May 23, 2014, 2:58:59 AM5/23/14
to robotframe...@googlegroups.com
Try this:

Input text and clear content before
    [Arguments]    ${seleniumLocator}    ${inputText}
    [Documentation]    ASCII Table: http://www.unix-manuals.com/refs/misc/ascii-table.html
    ...    CTRL-A -> 1
    ...    DEL (Delete) -> 127
    Press Key    ${seleniumLocator}    \1
    Press Key    ${seleniumLocator}    \127
    Input Text    ${seleniumLocator}    ${inputText}

Regards

Phuoc Ha

unread,
May 23, 2014, 5:52:55 AM5/23/14
to robotframe...@googlegroups.com
Hi guy,

It's very useful. I did it.
Thanks you very much!

Regards,
Phuoc Ha.

Vào 13:58:59 UTC+7 Thứ sáu, ngày 23 tháng năm năm 2014, mr đã viết:

Phuoc Ha

unread,
May 29, 2014, 11:55:20 PM5/29/14
to robotframe...@googlegroups.com
Hi Mr,

Please help me with keyboard down:

I research and I tried some ASCII keys, but It's not work:

    Press Key    ${txtUsername}    \\40
    Press Key    ${txtUsername}    \\68
    Press Key    ${txtUsername}    \\E65
    Press Key    ${txtUsername}    \\1001
    Press Key    ${txtUsername}    \\22480

What's ASCII key of keyboard down?
Please help!
Thanks you so much!



Vào 13:58:59 UTC+7 Thứ sáu, ngày 23 tháng năm năm 2014, mr đã viết:
Try this:

Kimlam Kim

unread,
May 30, 2014, 5:58:07 AM5/30/14
to phuo...@gmail.com, robotframework-users
Hi Phuoc,

In order to press key down, please try Presskey with the detailed in http://docs.oracle.com/javase/6/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED

In additional, you can use "Call Selenium API" keyword at http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/python/

For example

key_down(self, locator, keySequence)

source code 

Simulates a user pressing a key (without releasing it yet).

'locator' is an element locator 'keySequence' is Either be a string("" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", " 9".





--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Phuoc Ha

unread,
May 30, 2014, 8:05:38 AM5/30/14
to robotframe...@googlegroups.com, phuo...@gmail.com
Hi Limlan, 

Let me try your way (y).
Thanks Kimlan!

Vào 16:58:07 UTC+7 Thứ sáu, ngày 30 tháng năm năm 2014, Kimlam Kim đã viết:
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Wlad

unread,
Aug 21, 2015, 10:02:37 AM8/21/15
to robotframework-users
How can press or hold key(s) and especially key combinations like CTRL-A, CTRL-C etc. look like now since NAMED KEY value is available in Selenium2Library 1.7.3.?

Single keys is clear:

Press Key | <locator> | ENTER
Press Key | <locator> | DELETE  and so on ..

But what's with combinations like CTRL-A? How can I select a text in a textfield with CTRL-A so that I can delete it with 'Press Key | texfile_locator | DELETE' in the next step?




Hélio Guilherme

unread,
Aug 21, 2015, 10:14:07 AM8/21/15
to robotframework-users
We are still working on a solution for sending keys combinations.
There is a Press Keys keyword still under discussion of the features. Go to the Selenium2Library Github project pages if you are interested in its progress.


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Wlad

unread,
Aug 21, 2015, 10:31:01 AM8/21/15
to robotframework-users
Thanks for the information!

+1 for 'Press Keys'

Something like this would be great:

Press Keys | <locator> | CTRL_A
Press Keys | <locator> | CTRL + A
Press Keys | <locator> | CTRL + SHIFT + A
Press Keys | <locator> | CTRL | A
Press Keys | <locator> | CTRL | SHIFT | A

In Python Shell (after importing webdriver from selenium and keys from selenium.webdriver.common) this one worked for me to select text with CTRL-A:

>>> date = ff.find_element_by_xpath(<locator>)
>>> date.send_keys(keys.Keys.CONTROL,'a')


ff stand for 'webdriver.Firefox()'

Wlad

unread,
Aug 26, 2015, 8:04:10 AM8/26/15
to robotframework-users
Here is my suggestion for the 'Press Keys' keyword

def press_keys(self, locator, keys):
"""Simulates user pressing one or more KEY(s) or SPECIAL KEY(s) simultaniuosly or in sequence
on element identified by `locator` while HOLDING DOWN one or more MODIFICATION KEY(s).
`KEY`: 0-9, aA-zZ, -+*/% etc.
`SPECIAL KEY`: F1-F12, DEL, TAB, ARROW_UP/_DOWN/_LEFT/_RIGHT etc.
`MODIFICATION KEY`: ALT, ALT_GR, CTRL, R_CTRL, SHIFT, ALT_SHIFT, ALT_GR_SHIFT etc.
`KEY` is either a single character, (TODO: or a numerical ASCII code of the key lead by '\\\\'),
or a sequence of single characters.
`SPECIAL KEY` and `MODIFICATION KEY` are special key names defined at selenium.webdriver.common.keys.
Examples: # locator # key sequence # usage example
| Press Keys | <locator> | CONTROL + a | # select
| Press Keys | <locator> | CONTROL + A | # select
| Press Keys | <locator> | CONTROL + A | # select
| Press Keys | <locator> | CONTROL + C | # copy
| Press Keys | <locator> | CONTROL + V | # paste
| Press Keys | <locator> | CONTROL + ABC | # custom
| Press Keys | <locator> | CONTROL + SHIFT + A | # e.g. opens Firefox's Add-ons-Manager
| Press Keys | <locator> | CONTROL + ALT + DELETE | # e.g. shows lock screen on Windows
| Press Keys | <locator> | CTRL + ARROW_UP | # and so on
"""
keys =  keys.split(' + ')
i = 0
named_keys = []
named_key_sequence = []
for key in keys:
try:
named_key = getattr(Keys, keys[i])
print "%s. named key is %s." % (i + 1, key)
named_keys.append(keys[i])
i = i + 1
except:
print "The rest '%s' is unnamed." % key
unnamed = str(key).lower()
i = i + 1
print "NAMED KEY(s):", named_keys
for key in named_keys:
named_key_sequence.append('Keys.%s' % key)
named_key_seq_as_string = ','.join(named_key_sequence)
print "NAMED KEY SEQUENCE:", named_key_sequence
print "NAMED KEY SEQUENCE as STRING:", named_key_seq_as_string
print "element.send_keys() call should look like this:"
print "element.send_keys(%s, '%s')" % (named_key_seq_as_string, unnamed)
#select it
element = self._element_find(locator, True, True)
# execute 'press_keys' action
exec("element.send_keys(%s, '%s')" % (named_key_seq_as_string, unnamed))


Works nice for me. Hope it helps someone else, too :)
The only thing missing here yet is the use of numerical ASCII code.

Cheers

Wlad

unread,
Aug 26, 2015, 8:07:10 AM8/26/15
to robotframework-users
edit: little mistake above in the last line of documentation: CTRL is not supported ... instead one have to use CONTROL

Wlad

unread,
Aug 26, 2015, 8:41:27 AM8/26/15
to robotframework-users
Ok, the keyword needs some more testing and some more logic to handle special cases like 'CONTROL + +' or 'CONTROL + BACKSPACE'.
E.g. 'CONTROL + BACKSPACE' fails with "UnboundLocalError: local variable 'unnamed' referenced before assignment"

Wlad

unread,
Aug 26, 2015, 9:19:47 AM8/26/15
to robotframework-users
Fixed 'CONTROL + BACKSPACE' issue by assigning empty string '' to 'unnamed'.

Another known issue for now: 'CONTROL + +' or 'CONTROL + ++'  does not ZOOM IN in a browser as expected but 'CONTROL + -' does ZOOM OUT. 

Gaurav Deore

unread,
Mar 10, 2016, 3:01:18 AM3/10/16
to robotframework-users
Hi,

Is anyone worked on this??? 

Like : How can we press combination of keyboard keys in ROBOT FRAMEWORK?

is there any particular lib keyword can help to achive CONTROL + T etc?

Appreciate help on this?

Thanks,
Gaurav

Phuoc Ha

unread,
Mar 10, 2016, 11:14:28 PM3/10/16
to robotframework-users
You can use the imagehorizonlibrary: https://github.com/Eficode/robotframework-imagehorizonlibrary

Try this way:
Library           ImageHorizonLibrary

*** Test Cases ***
Try Press Ctrl + T With
ImageHorizonLibrary
   
Press combination    Key.ctrl    t


Regards,
Phuoc Ha

Vào 15:01:18 UTC+7 Thứ Năm, ngày 10 tháng 3 năm 2016, Gaurav Deore đã viết:

USMCMotorT

unread,
Jun 28, 2016, 9:17:43 AM6/28/16
to robotframework-users
Have you tried 

CTRL + a

I am not using RIDE at the moment but I am creating .robot files to run automation and CTRL + a works for me to select all. Lower Case a because when you normally use CTRL + a it is lower case and not a capital A.

Hopefully that does what you want.

indu prasad

unread,
Sep 16, 2016, 10:48:52 AM9/16/16
to robotframework-users

As per Phuoc Ha

Even  I need to pass "Alt+k" to my web application from RIDE.
which will do some operation in back end in web app,

Help me to resolve this.

Thanks, 

Phuoc Ha

unread,
Sep 17, 2016, 3:25:42 AM9/17/16
to robotframework-users
Hi Indu Prasad,

You can try this library, it's working very good -> https://github.com/Eficode/robotframework-imagehorizonlibrary
Example: https://github.com/Eficode/robotframework-imagehorizonlibrary/blob/master/tests/atest/windows_tests.robot

Regards,

Vào 21:48:52 UTC+7 Thứ Sáu, ngày 16 tháng 9 năm 2016, indu prasad đã viết:
Reply all
Reply to author
Forward
0 new messages