問題描述
是否有任何變通方法可以讓 HTML5 拖放與 Selenium Webdriver 和 Ruby 一起使用?我正在使用 Selenium-Webdriver 2.20.0 和 Ruby 1.9.2
Are there any work arounds to getting HTML5 Drag and Drop working with Selenium Webdriver with Ruby? I am using Selenium-Webdriver 2.20.0 with Ruby 1.9.2
這是一個重現(xiàn)問題的簡單測試:
Here is a simple test to reproduce the issue:
require "selenium-webdriver"
require "test/unit"
class Html5DragAndDropTest < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :firefox
@driver.manage.timeouts.implicit_wait = 30
end
def teardown
@driver.quit
end
def test_html5_drag_and_drop
@driver.get("http://html5demos.com/drag")
target = @driver.find_element(:id, "one")
source = @driver.find_element(:id, "bin")
@driver.action.drag_and_drop(target, source).perform
assert target.displayed? == false
end
end
推薦答案
這仍然是 Selenium 中的一個錯誤,所以上面提到的 JavaScript 解決方法是一個很好的解決方案.
This is still a bug in Selenium, so the JavaScript workaround noted above is a good one.
我構(gòu)建了 一個示例 HTML 拖放頁面,并編寫了一個測試來使用 Ryan 提供的 drag_and_drop_helper.js 要點.您可以在這里查看我的完整文章.
I built an example HTML drag and drop page and wrote a test to exercise it using the drag_and_drop_helper.js gist Ryan provided. You can see my full write-up here.
干杯,
戴夫 H
@TourDeDave
這篇關(guān)于使用 Selenium Webdriver for Ruby 進行 HTML5 拖放的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!