当前位置:网站首页>Selenium file upload method

Selenium file upload method

2022-06-29 17:40:00 bobob_

1. utilize AutoIT


2. Simulate keyboard to directly copy upload file path 
   Multiple document paths can be separated by spaces and double quotes 

public void windowsCtrlCV(TestStep step) throws Exception {
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("C:\\Users\\Desktop\\TestData3.pdf"),null);
    Thread.sleep(2000);
    try {
        if (Constants.ISDEBUG) System.out.println("『 Normal test 』 Start execution : " + "<" + step.getDesc() + ">");
        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_V);
        Thread.sleep(2000);

        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } catch (Exception e) {
        e.printStackTrace();
        if (Constants.ISDEBUG) System.err.println(Constants.LogCustom+"windowsCtrlCV");
    }
}

3. xpath yes input

 

原网站

版权声明
本文为[bobob_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/180/202206291732563142.html