使用 Selenium Webdriver for Ruby 进行 HTML5 拖放

HTML5 Drag and Drop using Selenium Webdriver for Ruby(使用 Selenium Webdriver for Ruby 进行 HTML5 拖放)
本文介绍了使用 Selenium Webdriver for Ruby 进行 HTML5 拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

是否有任何变通方法可以让 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

这是一个重现问题的简单测试:

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.

我构建了 一个示例 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

这篇关于使用 Selenium Webdriver for Ruby 进行 HTML5 拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社
ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)
Infinite scroll and will_paginate appending the #39;next page#39; of items multiple times(无限滚动和 will_paginate 多次附加项目的“下一页)