【问题标题】:How do I upload multiple files through selenium如何通过 selenium 上传多个文件
【发布时间】:2018-11-01 22:24:52
【问题描述】:

我在一个文件夹中有 4 张图片,需要将它们全部上传到我的应用程序中。我已经使用 sendKeys 通过 selenium 完成了单文件上传,但是多文件上传是一个挑战!

【问题讨论】:

标签: selenium-webdriver


【解决方案1】:
WebElement uploadElement = driver.findElement(By.xpath("   "));
//Single file upload
uploadElement.sendKeys("C:\\foldername\\abcd.png");

//Multi file upload - simultaneous
uploadElement.sendKeys("C:/foldername/firstImg.png \n C:/foldername/secondImg.png \n C:/foldername/thirdImg.png");

注意\n前面需要有空格

【讨论】:

    猜你喜欢
    • 2019-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    • 2015-04-28
    • 2019-12-23
    • 1970-01-01
    • 2021-10-18
    相关资源
    最近更新 更多