Mat*_*rix 5 javascript ruby watir instagram selenium-webdriver
我尝试在instagram上上传图片,所以我需要选择上传文件的路径

但我无法使用,form.file_field.send_keys(path)因为Instagram通过JS管理上传,因此该表单不存在,只有当我单击按钮“ +”时,才会出现“文件上传”窗口。
我尝试:
@browser.send_keys @path
@browser.send_keys :enter
Run Code Online (Sandbox Code Playgroud)
但也不行...
我没有找到与该子窗口“文件上载”进行交互以提供图像路径的方法。
任何的想法?
编辑:
<nav class="NXc7H f11OC "><div class="_8MQSO ZoygQ "><div class=""><div class="rBWT5"></div><div class="KGiwt"><div class="A8wCM"><div class="BvyAW"><div class="q02Nz"><a class="_0TPg" href="/"><span class="glyphsSpriteHome__outline__24__grey_9 u-__7" aria-label="Home"></span></a></div><div class="q02Nz"><a class="_0TPg" href="/explore/"><span class="glyphsSpriteSearch__outline__24__grey_9 u-__7" aria-label="Search & Explore"></span></a></div><div class="q02Nz _0TPg" role="menuitem" tabindex="0"><span class="glyphsSpriteNew_post__outline__24__grey_9 u-__7" aria-label="New Post" style=""></span></div><div class="q02Nz"><a class="_0TPg " href="/accounts/activity/"><span class="glyphsSpriteHeart__outline__24__grey_9 u-__7" aria-label="Activity"></span></a></div><div class="q02Nz"><a class="_0TPg" href="/tristan_grey_30/"><span class="glyphsSpriteUser__filled__24__grey_9 u-__7" aria-label="Profile"></span></a></div></div></div></div><form class="Q9en_" enctype="multipart/form-data" method="POST" role="presentation"><input accept="image/jpeg" class="tb_sK" type="file"></form></div></div></nav>
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用<form>contain in <nav>,什么也没有发生,所以在“ +”上有onClick事件:
{
!0 !== this.$_MobileNav2 && (this.$_MobileNav2 = !0, r(d[1]).logAction_DEPRECATED('cameraIconClick'), this.$_MobileNav3 ? (this.$_MobileNav3.selectFile(), this.props.onStartCreation()) : (i(d[2])('No image form'), this.props.onImageFormError()), this.$_MobileNav2 = !1)
}
Run Code Online (Sandbox Code Playgroud)
我认为是由JS管理...
您不会喜欢这个答案,但也Watir不会以任何方式与操作系统打开的窗口进行交互。更进一步,Ruby 本身并不与这些操作系统级别的对话进行交互。
您可能需要参考以下几件事来确认这一点,这是完全可以接受的:
Capybara::Node::Actions#attach_file无论如何,您尝试与一个无法通过 Ruby 进行交互的对象进行交互,更不用说 Watir,因此您想要的解决方案是不可能的。
最好的例子是水豚attach_file方法。如果这不起作用,那么除了文字操作系统脚本语言(例如AutoIt或Sikuli
您可以在此处找到 SikuliX 项目页面。DrapsTV 制作了一个大约一个小时的播放列表,介绍 SikuliX 的设置和快速入门。该系列第一集的链接位于此处。
祝你好运。
| 归档时间: |
|
| 查看次数: |
327 次 |
| 最近记录: |