I'm trying to build a framework using Selenium. There is a scenario where I need to download a file, and there is another where I need to upload one. I've gone through the option in AutoIt, but it doesn't allow me to put in a varying filename. Then I came across Robot where in I can send custom strings. However, for some reason, the piece of code is not entering text into the field. I see that the cursor is in the field, but the text is not getting entered. What could be the reason?
Also, is there an option to make the mouse click on a particular button, say Open/Cancel using Robot?(Just like AutoIT can do)
String text = "sampledoc.txt";
StringSelection stringSelection = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection);
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_V);
r.keyRelease(KeyEvent.VK_V);
r.keyRelease(KeyEvent.VK_CONTROL);