1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| slider := "jspath" data := "滑动距离" code := `var slider = ` + slider + `; var rect = slider.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + ` + data + ` y1 = y0;
var mousedown = document.createEvent('MouseEvents'); mousedown.initMouseEvent('mousedown', true, true, window, 0, x0, y0, x0, y0, false, false, false, false, 0, null); slider.dispatchEvent(mousedown);
var mousemove = document.createEvent('MouseEvents'); mousemove.initMouseEvent('mousemove', true, true, window, 0, x1, y1, x1, y1, false, false, false, false, 0, null); slider.dispatchEvent(mousemove);
var mouseout = document.createEvent('MouseEvents'); mouseout.initMouseEvent('mouseup', true, true, window, 0, x1, y1, x1, y1, false, false, false, false, 0, null); slider.dispatchEvent(mouseout);` //滑动滑块 chromedp.Run(ctx, chromedp.Tasks{ chromedp.EvaluateAsDevTools(code, nil), })
|