如何通过硒上传多个文件 [英] How do I upload multiple files through selenium

查看:64
本文介绍了如何通过硒上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have 4 images in a folder and need to upload all of them together into my application. I have done single file upload through selenium using sendKeys, but the multi file upload is a challenge!

推荐答案

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必须以空格开头

这篇关于如何通过硒上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆