如何在firefox上使用selenium上传dropzone中的图片

时间:2015-07-31 12:41:40

标签: javascript firefox selenium capybara

我与Capybara(2.4.4),Selenium-webdriver(2.47.0)和Firefox(39)合作。

我应该在点击和放置元素上传图片:http://screencast.com/t/jRCo4D0F

我使用了来自this article的解决方案。

在chrome 中可行!但是在firefox中不是

它失败了:

$('.dropzone')[0].dropzone.listeners[0].events.drop(e);

有错误:

Selenium::WebDriver::Error::JavascriptError: e is undefined
[remote server] https://master-site.somesitename.org/assets/account-d0fc2c2c.js:19:in `t</t.prototype.addFile'
[remote server] https://master-site.somesitename.org/assets/account-d0fc2c2c.js:18:in `t</t.prototype.handleFiles'
[remote server] https://master-site.somesitename.org/assets/account-d0fc2c2c.js:18:in `t</t.prototype.drop'
[remote server] https://master-site.somesitename.org/assets/account-d0fc2c2c.js:18:in `t</t.prototype.init/this.listeners<.events.drop</<'
[remote server] https://master-site.somesitename.org/en/my/products/68213/photos line 68 > Function:3:in `anonymous'
[remote server] https://master-site.somesitename.org/en/my/products/68213/photos:68:in `handleEvaluateEvent'
./framework/support/capybara_extension.rb:73:in `drop_in_dropzone'
./framework/ep-logic/guide_logic.rb:81:in `create_new_private_tour'
./spec/guide_spec.rb:30:in `block (3 levels) in <top (required)>'
-e:1:in `load'
-e:1:in `<main>'

我尝试手动运行firebug控制台中的每个js。一切运作良好,图片上传。

请,需要帮助!如何在Firefox中修复图片上传?

1 个答案:

答案 0 :(得分:0)

我正在将c#与硒结合使用,以使用javascript自动执行图像上传,如下所示 TraversableLike

让我解释一下这件事是如何工作的吗?在我的情况下,我们使用其ID(即“ images-dropzone”)定位dropzone。您需要将其替换为自己的产品。我们正在传递base64Image字符串,并且有一些在线工具可以为您提供base64图像输出。将您的图像字符串传递给@“ base64Image。如果需要动态生成base64字符串,请告知我也可以共享该代码。希望对您有帮助