RubyでSelenium WebDriverを使用してドラッグアンドドロップ機能を実装しようとしています。それを達成するために、私は次のことを行いました:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.get "myurl"
source = driver.find_element(:id, '19026240')
target = driver.find_element(:xpath, "//div[@id='rootLabelChildren']/div/div")
driver.action.drag_and_drop(source, target).perform
これは、要素が見つからない、要素が DOM にアタッチされていないなどのエラーにはなりませんが、タイムアウト エラーが発生します。
Timeout::Error: Timeout::Error
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for
'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:607:in `execute'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:394:in `mouseMoveTo'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/mouse.rb:54:in `move_to'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/action_builder.rb:344:in `block in
perform'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/action_builder.rb:343:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/action_builder.rb:343:in `perform'
from (irb):6
from C:/Ruby193/bin/irb:12:in `<main>'irb(main):007:0> end
SyntaxError: (irb):7: syntax error, unexpected keyword_end
from C:/Ruby193/bin/irb:12:in `<main>'
手動では、ドラッグ アンド ドロップは適切に機能します。タイムアウトエラーの原因は何ですか?
Firefox バージョン: 21 Selenium WebDriver: 2.33.0
HTML コード:
ターゲット用
<div id="rootLabelChildren" class="children">
<div class="label " labelid="74ce292d65844af7b4e480782d8e9b38" labelname="0106">
<div class="labelName terminal" draggable="true">0106</div>
<div class="children"> </div>
</div>
ソース用
<table class="dataGridHeader">
<div class="dataGridScrollbarContainer scrollable" style="">
<div class="dataGridContents" style="min-height: 12880px;">
<table class="buffer" style="margin-top: 0px;">
<tbody>
<tr id="19026240" class="selected" draggable="true">