2

In Robot Framework how do I give the ctrl+c command?

I have tried this line but it does not work

${crtl_c}    Evaluate    chr(int(3))    SSHLibrary.Write Bare    ${crtl_c}
Goralight
  • 2,067
  • 6
  • 25
  • 40
Teja
  • 21
  • 1
  • 3

5 Answers5

0

Use imagehorizon as a library :

Press Combination    KEY.CTRL    C
Emna Ayadi
  • 2,430
  • 8
  • 37
  • 77
0

Use PyAutoGUI

PyAutoGUI works on Windows/Mac/Linux on Python 2 & 3. Install from PyPI with pip install pyautogui

import pyautogui

def CntrlC():
    pyautogui.hotkey('ctrl', 'c') #Performs ctrl+c

Now just import the py file and use CntrlC as the Keyword

Aneez Ahmed
  • 113
  • 1
  • 6
0
${ctrl_c}    evaluate    chr(int(3))
SSHLibrary.Write Bare    ${crtl_c}

Or else you can give the line in variables section:

***variable***
${ctrl_c}    evaluate    chr(int(3))
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
0

Just got this working. The problem with the answers above is that you need an equal sign.

${ctrl-c}=                  evaluate      chr(int(3))
Write Bare                  ${ctrl-c}
-1

Refering to a previous answer on an SO question where if you're on windows, the SendKeys python library is used to send actual key presses to the system. In case you're on a linux based system it pretty much depends on the GUI you're using and a few other factors. This SO Question has some good content that might help you.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
  • The problem is related with SSHLibrary. The solution may be by finding the right numeric value for the Ctrl-C combination. From the old days, I used to send (not on SSH) Ctrl-G (007) to make the terminal beep. If that works, you could try `Write Bare "\\007"` – Helio May 29 '17 at 10:23