你可以试着和这些功能(我使用phpwebdriver)
/**
* Move the mouse by an offset of the specificed element.
* If no element is specified, the move is relative to the current mouse cursor.
* If an element is provided but no offset, the mouse will be moved to the center of the element.
* If the element is not visible, it will be scrolled into view.
*
* @param WebElement $element
* ID of the element to move to. If not specified or is null,
* the offset is relative to current position of the mouse.
* @param integer $xoffset
* X offset to move to, relative to the top-left corner of the element.
* If not specified, the mouse will move to the middle of the element.
* @param integer $yoffset
* Y offset to move to, relative to the top-left corner of the element.
* If not specified, the mouse will move to the middle of the element.
*/
public function moveTo($element = null, $xoffset = null, $yoffset = null)
{
$request = $this->requestURL . "/moveto";
$session = $this->curlInit($request);
$array = explode('/', $element->requestURL);
$id = $array[count($array) - 1];
$args = array();
if($element) $args['element'] = $id;
if($xoffset) $args['xoffset'] = intval($xoffset);
if($yoffset) $args['yoffset'] = intval($yoffset);
if(empty($args))
$this->preparePOST($session, null);
else{
$postargs = json_encode($args);
$this->preparePOST($session, $postargs);
}
curl_exec($session);
}
/**
* Click and hold the left mouse button (at the coordinates set by the last moveto command).
* Note that the next mouse-related command that should follow is buttonUp() .
* Any other mouse command (such as click() or another call to buttonDown()) will yield undefined behaviour.
*
* @param integer $button
* Which button, enum: {LEFT = 0, MIDDLE = 1 , RIGHT = 2}.
* Defaults to the left mouse button if not specified.
*/
public function buttonDown()
{
$request = $this->requestURL . "/buttondown";
$session = $this->curlInit($request);
$this->preparePOST($session, null);
curl_exec($session);
}
/**
* Releases the mouse button previously held (where the mouse is currently at).
* Must be called once for every buttonDown() command issued.
* See the note in click and buttonDown() about implications of out-of-order commands.
*
* @param integer $button
* Which button, enum: {LEFT = 0, MIDDLE = 1 , RIGHT = 2}.
* Defaults to the left mouse button if not specified.
*/
public function buttonUp()
{
$request = $this->requestURL . "/buttonup";
$session = $this->curlInit($request);
$this->preparePOST($session, null);
curl_exec($session);
}
/**
* Maximize the specified window if not already maximized.
* If the :windowHandle URL parameter is "current", the currently active window will be maximized.
*/
感谢您的回答@stirno。我知道这个命令,尽管我没有成功实现它到我的测试中。似乎我的问题中的代码显示为灰色,在div之前有#document-fragment。所以我想知道这是否锁定,因此不允许我能够自动化滑块?我已经包含了一个说明灰色代码的截图。 http://screencast.com/t/zGUj64ZRS –