Skip to content

Commit

Permalink
Merge pull request #13 from creative-commoners/pulls/1.1/drag-and-drop
Browse files Browse the repository at this point in the history
FIX Perform drag and drop
  • Loading branch information
Maxime Rainville authored Nov 10, 2021
2 parents 1312fd0 + c59dcd1 commit 98d82e5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/FacebookWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -973,14 +973,39 @@ public function keyUp($xpath, $char, $modifier = null)
$this->trigger($xpath, 'keyup', $options);
}

/**
* Globally press a key i.e. not typing into an element
*/
public function globalKeyPress($char, $modifier = null)
{
/** @var RemoteKeyboard $keyboard */
$keyboard = $this->webDriver->getKeyboard();
if ($modifier) {
$keyboard->pressKey($modifier);
}
$keyboard->pressKey($char);
if ($modifier) {
$keyboard->releaseKey($modifier);
}
}

/**
* {@inheritdoc}
*/
public function dragTo($sourceXpath, $destinationXpath)
{
$source = $this->findElement($sourceXpath);
$destination = $this->findElement($destinationXpath);
$this->webDriver->action()->dragAndDrop($source, $destination);
$this->webDriver->action()->dragAndDrop($source, $destination)->perform();
}

/**
* Drag and drop an element by x,y pixels
*/
public function dragBy($sourceXpath, $xOffset, $yOffset)
{
$source = $this->findElement($sourceXpath);
$this->webDriver->action()->dragAndDropBy($source, $xOffset, $yOffset)->perform();
}

/**
Expand Down

0 comments on commit 98d82e5

Please sign in to comment.