Handle file upload control on hidden input not working

Hello,

I tried to upload a file on hidden input by javascriptExecutor as mentioned in https://docs.katalon.com/katalon-studio/docs/handle-file-upload-control-on-hidden-input.html but it didn’t work for me and for second option using robot ,it just worked for 1st time.From next time file path is not getting set in “File name” input Box.

My code using robot:

void uploadFile(TestObject to, String filePath) {
    WebUI.click(to)
    StringSelection ss = new StringSelection(filePath);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
}

Is there any way so that second time also it works?