Multiple files upload in selenium webdiver

后端 未结 4 2095
鱼传尺愫
鱼传尺愫 2021-01-15 23:50

I want to upload 5 files,but my \'file input\' is same name/id,how can i possible to upload five files. My HTML code is:

4条回答
  •  青春惊慌失措
    2021-01-16 00:28

    You would do so the same as you would if you were only uploading one file.

    driver.findElement(By.id("input1")).sendKeys("path/to/first/file");
    driver.findElement(By.id("input2")).sendKeys("path/to/second/file");
    driver.findElement(By.id("input3")).sendKeys("path/to/third/file");
    driver.findElement(By.id("input4")).sendKeys("path/to/fourth/file");
    driver.findElement(By.id("input5")).sendKeys("path/to/fifth/file");
    driver.findElement(By.id("upload")).click();
    

    Obviously, you'll need to put in your own correct IDs or whatever.

提交回复
热议问题