【问题标题】:How to upload file in readonly text from selenium using xpath as sendkeys won't work如何使用 xpath 作为 sendkeys 从 selenium 上传只读文本文件将不起作用
【发布时间】:2018-10-11 04:44:13
【问题描述】:

这是结构:

<input _ngcontent-c9="" class="form-field" placeholder="Upload Emote" readonly="" type="text">

我已使用以下代码上传文件,但 sendkeys 无法正常工作,我没有收到任何错误但无法上传。

    WebElement uploadingEmote = adminDriver.findElement(By.xpath("//input[@placeholder='Upload Emote']"));
    uploadingEmote.sendKeys("/home/smart/Downloads/EMO/(Heart).png");

但上面的代码不起作用,因为该字段是只读的。 任何帮助将不胜感激。

this is the screenshot:

【问题讨论】:

  • 代码不工作到底是什么意思?你看到任何错误吗?更新问题

标签: java html angularjs selenium file-upload


【解决方案1】:
<input _ngcontent-c9="" class="form-field" placeholder="Upload Emote" readonly="" type="text">

如果您要上传文件,您的输入字段类型应为“文件”类型

<input type="file" name="fileToUpload" id="fileToUpload">

【讨论】:

    猜你喜欢
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    相关资源
    最近更新 更多