[英]How to upload the file using Junit Selenium?
I tried to upload the file using JUNIT_Selenium. 我尝试使用JUNIT_Selenium上传文件。
WebElement fileInfo = driver.findElement(By.xpath("//input[@type='file']"));
fileInfo.sendKeys('my file root');
But, the popup window was not closed in this way :( 但是,弹出窗口没有以这种方式关闭:(
Cloud you please give me the answer to solve this problem? 云你请给我答案解决这个问题?
(browser used : Chrome) (使用的浏览器:Chrome)
I have used some special library Robot. 我已经使用了一些特殊的机器人库。
details.ClickChooseFile();
StringSelection ss = new StringSelection("C:\\Your File");
waitmethod.Waitsec();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
Robot robot = new Robot();
waitmethod.Waitsec();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
details.ClickSubmitEmpl();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.