【发布时间】:2019-05-16 10:19:40
【问题描述】:
我的自动化脚本需要将图像上传到网页,但我似乎无法使用普通的 send_keys 方法上传图像。我怀疑它与 Angular 组件有关,但我不确定如何使用 Selenium webdriver 访问它们。
我尝试了以下方法: Automate file upload using Selenium and ng-file-upload 和How to upload file using python+selenium?
这些似乎没有我正在寻找的解决方案。
<button class="md-raised choose-file md-button md-ink-ripple ng-empty ng-valid" type="button" ng-transclude="" ngf-select="" accept="image/*" ng-model="vm.uploader.original" aria-invalid="false">Choose file</button>
我没有任何错误,因为我可以成功定位元素,但图片没有上传/发送。
file_input.send_keys("/location/of/image/profile_student.jpg")
【问题讨论】:
-
Choose file按钮旁边有输入框吗?或者您正在点击Choose file按钮及其弹出窗口? -
@KunduK 不,我只有选择文件按钮。单击它后,它会打开“打开文件”弹出框。
-
好的。要访问 windows 对象,您需要使用 autoit 和 selenium。
标签: python angularjs selenium selenium-webdriver browser-automation