How to automate keyboard actions/upload a file using ROBOT Class in Selenium?

Описание к видео How to automate keyboard actions/upload a file using ROBOT Class in Selenium?

In this video will see how to upload any file in selenium webdriver by using ROBOT class.

I have shown how to implement /automate keyboard/mouse actions like ctrl+c,ctrl+v,pg up,pg dn,end,space,shift,delete,end etc.

I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: [email protected]


Details:
https://programmerworld.co/selenium/h...

public static void main(String[] args) throws AWTException {
// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver", "Path of chromedriver exe\\chromedriver.exe");
ChromeOptions op = new ChromeOptions();
op.setBinary("Path of chromexe\\chrome.exe");
op.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(op);

driver.get("https://programmerworld.co/selenium-t...");
driver.findElement(By.id("mfcf7_zl_add_file")).click();

Robot robo = new Robot();

StringSelection str = new StringSelection("BullseyeCoverageError.txt");

Toolkit.getDefaultToolkit().getSystemClipboard().setContents(str, null);

robo.keyPress(KeyEvent.VK_CONTROL);
robo.keyPress(KeyEvent.VK_V);

robo.keyRelease(KeyEvent.VK_CONTROL);
robo.keyRelease(KeyEvent.VK_V);

robo.keyPress(KeyEvent.VK_ENTER);
robo.keyRelease(KeyEvent.VK_ENTER);
}

--

Комментарии

Информация по комментариям в разработке