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: programmerworld1990@gmail.com
Details:
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-test-page/");
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);
}
Excerpt:
In this video, the process of uploading files in Selenium WebDriver using the Robot class is demonstrated. The narrator showcases the implementation and automation of keyboard and mouse actions such as Ctrl+C, Ctrl+V, Pg Up, Pg Dn, End, Space, Shift, and Delete. The accompanying code includes the setup of ChromeDriver with specific options, navigating to a test page, and simulating file upload using the Robot class. Additionally, contact information for inquiries or feedback is provided. The video also includes screenshots of the demonstrated process.