我的产品中有一项功能,可让用户选择多个文件并上传。我正在尝试使用硒自动化它。即使代码在Windows中运行良好,在Ubuntu上通过Jenkins运行测试用例时也不会发生文件上载。有人可以帮我找到错误吗?
编辑:使用Jenkins主目录,图像目录,图像名称和File.Separator
构建图像的完整路径 // Copying the path of the file to the clipboard
StringSelection photo = new StringSelection("complete/path/image1" "complete/path/image2" "complete/path/image3" "complete/path/image4"));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(photo, null);
Thread.sleep(10000); // Some sleep time to detect the window popup
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
// To Click on the "Open" button to upload files
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
WebElement postImageButton = driver.findElement(Properties.CompleteUploadButton);
CompleteUploadButton.click();