Java 如何使用xpath作为sendkeys从selenium上传只读文本文件;行不通
结构如下:Java 如何使用xpath作为sendkeys从selenium上传只读文本文件;行不通,java,html,angularjs,selenium,file-upload,Java,Html,Angularjs,Selenium,File Upload,结构如下: 我使用下面的代码上传文件,但sendkeys不工作,我没有收到任何错误,但无法上传 WebElement uploadingEmote = adminDriver.findElement(By.xpath("//input[@placeholder='Upload Emote']")); uploadingEmote.sendKeys("/home/smart/Downloads/EMO/(Heart).png"); 但是上
我使用下面的代码上传文件,但sendkeys不工作,我没有收到任何错误,但无法上传
WebElement uploadingEmote = adminDriver.findElement(By.xpath("//input[@placeholder='Upload Emote']"));
uploadingEmote.sendKeys("/home/smart/Downloads/EMO/(Heart).png");
但是上面的代码不起作用,因为字段是只读的。
任何帮助都将不胜感激
如果要上载文件,输入字段的类型应为“文件”类型
<input type="file" name="fileToUpload" id="fileToUpload">
您所说的代码不起作用到底是什么意思?你看到什么错误了吗?更新问题
<input type="file" name="fileToUpload" id="fileToUpload">