Created
September 27, 2013 06:59
-
-
Save sebv/6725034 to your computer and use it in GitHub Desktop.
SVG drag and drop with firefox driver
This file contains hidden or 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
var wd; | |
try { | |
wd = require('wd'); | |
} catch( err ) { | |
wd = require('../lib/main'); | |
} | |
var browser = wd.promiseRemote(); | |
var Q = browser.Q; | |
// request logging | |
browser.on('status', function(info){ | |
console.log('\x1b[36m%s\x1b[0m', info); | |
}); | |
browser.on('command', function(meth, path, data){ | |
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | |
}); | |
function dragNDrop(fromId, toId) { | |
return function() { | |
return Q.all([ | |
browser.elementById(fromId), | |
browser.elementById(toId), | |
]).then(function(els) { | |
return browser | |
.moveTo(els[0]) | |
.buttonDown() | |
.moveTo(els[1]) | |
.buttonUp(); | |
}); | |
}; | |
} | |
browser | |
.init({browserName: 'firefox'}) | |
.get('http://svg-whiz.com/svg/DragAndDrop.svg') | |
.then( dragNDrop("GreenRectangle", "BackDrop") ) | |
.catch(function(err) { | |
console.log(err.stack); | |
}) | |
.sleep(5000) | |
//.quit() | |
.done(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment