我正在尝试文件上传。我已经尝试过这段代码
driver.findElement(By.id("documents")).click();
driver.get("C:"+File.separator+"exp"+File.separator+"tt.docx");
driver.findElement(By.id("page"));
Actions ac = new Actions(driver);
WebElement element = driver.findElement(By.id("page"));
ac.click(element).perform();
Robot r = new Robot();
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
r.keyPress(KeyEvent.VK_C);
r.keyRelease(KeyEvent.VK_C);
r.keyPress(KeyEvent.VK_PERIOD);
r.keyRelease(KeyEvent.VK_PERIOD);
r.keyPress(KeyEvent.VK_J);
r.keyRelease(KeyEvent.VK_J);
r.keyPress(KeyEvent.VK_P);
r.keyRelease(KeyEvent.VK_P);
r.keyPress(KeyEvent.VK_G);
r.keyRelease(KeyEvent.VK_G);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
执行此代码文件的文件夹已打开但未在文本框中写入(文件路径)。我的输入 type=file 是只读的。有谁能够帮我?