英文:
File pathway field cannot be filled with Selenium (Python)
问题
我尝试添加一个需要使用Selenium(Chromedriver)上传的文件路径,但失败了。我的疑惑是是否可以使用标签autocomplete="off"。
Input:
<input id="loadFileControl-1287-inputEl" type="text" role="textbox" size="1" name="" readonly="readonly" class="x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" data-errorqtip="<ul class="x-list-plain"><li>This field is required</li></ul>" style="width: 100%;">
我的Selenium尝试:
input_field = driver.find_element("xpath", "//input[@class='x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus']")
input_field.send_keys('file_name.xml')
input_field.click()
有效,所以我认为我正确地指向了元素。
谢谢。
英文:
I tried to add a path to file that needs to be uploaded with Selenium (Chromedriver) and failed. My doubt is if it is possible with tag autocomplete="off".
Input:
<input id="loadFileControl-1287-inputEl" type="text" role="textbox" size="1" name="" readonly="readonly" class="x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" data-errorqtip="<ul class=&quot;x-list-plain&quot;><li>This field is required</li></ul>" style="width: 100%;">
My attempt in Selenium:
input_field = driver.find_element("xpath", "//input[@class='x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus']")
input_field.send_keys('file_name.xml')
input_field.click()
works so I assume I point the element correctly.
Thank you.
答案1
得分: 1
你试图输入的字段是只读的。你可以点击它,但是正如属性所示,你无法编辑它。
<input id="loadFileControl-1287-inputEl" type="text" role="textbox" size="1" name="" readonly="readonly" class="x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" data-errorqtip="<ul class="x-list-plain"><li>This field is required</li></ul>" style="width: 100%;">
英文:
The field youre trying to input into is read only. You can click on it but like the attribute says, you cant edit it.
<input id="loadFileControl-1287-inputEl" type="text" role="textbox" size="1" name="" readonly="readonly" class="x-form-field x-form-required-field x-form-text x-form-invalid-field x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" data-errorqtip="<ul class=&quot;x-list-plain&quot;><li>This field is required</li></ul>" style="width: 100%;">
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论