dushkin
dushkin

Reputation: 2101

Java: Sending text to windows on Linux

I am running some automation on Linux (over docker), specifically automating some Firefox actions.

At one stage I need to send text to an "Upload file" text box.

This specific example is from windows, but the test runs on Linux

This specific example is from windows, but the test runs on Linux.

I found no clue how can I achieve that.

Can you assist please?

Regards!

Upvotes: 0

Views: 52

Answers (1)

Joni
Joni

Reputation: 111239

In Java, you can generate key press events with the Robot class. This code presses the A key:

    Robot robot = new Robot(); 
    robot.keyPress(KeyEvent.VK_A); 

There's a complete example at https://www.geeksforgeeks.org/robot-class-java-awt/ and you can find many more by searching on the internet for "Java robot automation" or similar search terms

Upvotes: 1

Related Questions