Village
Village

Reputation: 24373

How to simulate typing keyboard keys and <tab> from a BASH script?

I must enter a lot of data into the forms on a workplace Web site. I already have data in a spreadsheet, but must essentially type in the data manually. I would like to create a BASH script which types in the data into the Web browser to save time.

Is it possible to have a BASH script do things like type keys on the keyboard, such as numbers, and [tab], while focused on my browser window? With this, I could easily create a BASH script which automatically enters the data I need.

The answer in Is there a way to trigger a Hot Key/Keyboard Shortcut via a Shell Script, a AppleScript or a Automator Workflow? useful, but is only for OS X, while I use Debian.

Upvotes: 0

Views: 1602

Answers (1)

arutaku
arutaku

Reputation: 6087

You can get it importing "Selenium" in java / python... code. You are interested in method sendKeys.

Here is an example:

WebElement.sendKeys(Keys.RETURN);

You can encapsulate Selenium's calls in a small java code that you call from a shell script, keeping the logic in your script.

Upvotes: 1

Related Questions