Created
September 27, 2013 02:02
-
-
Save sivajankan/6723239 to your computer and use it in GitHub Desktop.
Capybara cuke drag and drop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'capybara' | |
require 'capybara/dsl' | |
Capybara.run_server = false | |
Capybara.current_driver = :selenium | |
class Test | |
include Capybara::DSL | |
def test_google | |
sleep_time = 0.6 # time to see visual effects manually | |
visit('http://www.uize.com/examples/drag-to-move.html?tour=drag-and-drop') | |
#added exception catching for analysing scripts process issues | |
begin | |
#left = page.evaluate_script("document.getElementById('uizeGuid4').style.left") | |
#top = page.evaluate_script("document.getElementById('uizeGuid4').style.top") | |
page.execute_script("document.getElementById('uizeGuid4').style.zIndex=100") | |
while(1) | |
[[120,160], [160, 120], [280, 60], [400, 80], | |
[450,150], [430, 220], [350, 280], [230, 250]].each do |left, top| | |
page.execute_script("document.getElementById('uizeGuid4').style.left='#{left.to_i+10}px'") | |
page.execute_script("document.getElementById('uizeGuid4').style.top='#{top.to_i+10}px'") | |
sleep(sleep_time) | |
end | |
end | |
#All the best | |
rescue Exception => exp | |
puts exp.to_s | |
end | |
end | |
end | |
t = Test.new | |
t.test_google |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment