HTML5拖放使用Selenium Webdriver for Ruby [英] HTML5 Drag and Drop using Selenium Webdriver for Ruby

查看:101
本文介绍了HTML5拖放使用Selenium Webdriver for Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何工作可以让HTML5拖放与使用Ruby的Selenium Webdriver一起使用?我正在使用Selenium-Webdriver 2.20.0与Ruby 1.9.2



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

  requireselenium-webdriver
requiretest / unit

class Html5DragAndDropTest< Test :: Unit :: TestCase

def setup
@driver = Selenium :: WebDriver.for:firefox
@ driver.manage.timeouts.implicit_wait = 30
结束

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


解决方案

p>这仍然是Selenium中的一个错误,所以上面提到的JavaScript解决方法是一个很好的例子。



我构建了一个HTML拖放页面,并写了一个测试,使用 drag_and_drop_helper.js gist Ryan提供的。您可以在此处查看我的完整报告。



干杯,

Dave H

@TourDeDave


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

解决方案

This is still a bug in Selenium, so the JavaScript workaround noted above is a good one.

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.

Cheers,
Dave H
@TourDeDave

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆