本文介绍了如何使用CasperJS移动jquery-ui滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以将 jQuery UI – Slider 与 CasperJS 吗?
Is there any way to move the jQuery UI – Slider with CasperJS ?
我还发现了这个 github问题,同时寻找了一种可能性,只需点击向左或向右滑动滑块以移动手柄.但这对我也不起作用.
I also found this github issue while searching for a possibility to just click on the left or right of the slider to move the handle. But this doesn't worked for me as well.
有什么主意吗?
推荐答案
这是完整的演示:
// test_slider.js
var casper = require('casper').create(),
mouse = require('mouse').create(casper),
utils = require('utils');
casper.start('http://jqueryui.com/resources/demos/slider/default.html')
.then(function() {
var slider = this.getElementBounds('.ui-slider');
var handle = this.getElementBounds('.ui-slider-handle');
this.echo('=== BEFORE ===', 'INFO');
this.echo(this.getElementAttribute('.ui-slider-handle', 'style'));
this.capture('before.png');
this.echo('=== DRAGGING ===', 'INFO');
this.mouse.down('.ui-slider-handle');
this.mouse.move(slider.left + slider.width / 2, slider.top + slider.height / 2);
this.mouse.up('.ui-slider-handle');
this.echo('=== AFTER ===', 'INFO');
this.echo(this.getElementAttribute('.ui-slider-handle', 'style'));
this.capture('after.png');
})
.run();
结果
$ casperjs test_slider.js
=== BEFORE ===
left: 0%;
=== DRAGGING ===
=== AFTER ===
left: 50%;
这篇关于如何使用CasperJS移动jquery-ui滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!