Question

Is it possible to imitate keyboard input via Command Line or Python Code in digitalocean headless 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.find_element_by_tag_name(‘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.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.