![](/img/trans.png)
[英]How to upload a file through the js-doc-upload button, using Selenium WD + Java + JUnit?
[英]How to upload the file using Junit Selenium?
我嘗試使用JUNIT_Selenium上傳文件。
WebElement fileInfo = driver.findElement(By.xpath("//input[@type='file']"));
fileInfo.sendKeys('my file root');
但是,彈出窗口沒有以這種方式關閉:(
雲你請給我答案解決這個問題?
(使用的瀏覽器:Chrome)
我已經使用了一些特殊的機器人庫。
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.