为了账号安全,请及时绑定邮箱和手机立即绑定

无法使用 Selenium 上传文件

无法使用 Selenium 上传文件

江户川乱折腾 2022-06-14 10:14:51
我有以下用于文件上传的 HTML。<div class="drop-zone hand-cursor ng-pristine ng-untouched ng-valid ng-empty" ngf-select="" ngf-drop="" data-ngf-pattern=".pdf" data-ngf-accept="application/pdf" data-ng-model="vm.siteVo.signed_order_form">    <!-- ngIf: !vm.siteVo.signed_order_form -->    <div ng-if="!vm.siteVo.signed_order_form" class="ng-scope"><i class="material-icons primary-color font-size-40">backup</i>        <br><span class="color54 font-size-16 ng-binding">Drag and drop file here or click to open explorer</span></div>    <!-- end ngIf: !vm.siteVo.signed_order_form -->    <!-- ngIf: vm.siteVo.signed_order_form --></div>我尝试了以下方法来定位driver.find_element_by_css_selector(".drop-zone > .ng-scope").send_keys("file path")但出现以下错误selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable  (Session info: chrome=77.0.3865.90)
查看完整描述

1 回答

?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

已解决:inputwithtype file不在同一个div页面中,而是随机放置在页面中。使用 xpath 定位并直接使用send_keys()



查看完整回答
反对 回复 2022-06-14
  • 1 回答
  • 0 关注
  • 101 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号