Is it possible to imitate keyboard input via Command Line or Python Code in digitalocean headless Ubuntu?

January 16, 2017 263 views
DigitalOcean System Tools Python Ubuntu

Is it possible to imitate Keyboard input via Command Line or Python Code?
If possible, do I have to additionally install some kind of Dependencies to make keyboard input?
I am worried that I can't generate keyboard input because digitalocean linux doesn't have real keyboard or input device attached to it.

I am currently using Selenium with python, and there are lines of code which imitates keyboard input to a Firefox browser. For example,

from selenium.webdriver.common.keys import Keys
driver.findelementbytagname('body').send_keys(Keys.CONTROL + 't')

Unfortunately, this code doesn't work, after trying a lot of tests.

I found that the code I used actually runs well on my local linux, which has real keyboard device.

I think I'm sure that being unable to give keyboard input is not Selenium nor other third-party software problem. I guess the problem resides in the fact that Ubuntu is headless and doesn't have input device attached to it.

1 comment
  • The code (from selenium.webdriver.common.keys import Keys
    driver.findelementbytagname('body').send_keys(Keys.CONTROL + 't'))
    is in digitalocean Ubuntu, and Everytime I run the code I can confirm that the code isn't working.