updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -0,0 +1,16 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
/**
* Move to the location and then release the mouse key.
*/
class WebDriverButtonReleaseAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->mouseUp($this->getActionLocation());
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
class WebDriverClickAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->click($this->getActionLocation());
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
/**
* Move the the location, click and hold.
*/
class WebDriverClickAndHoldAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->mouseDown($this->getActionLocation());
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
/**
* You can call it 'Right Click' if you like.
*/
class WebDriverContextClickAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->contextClick($this->getActionLocation());
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Exception\UnsupportedOperationException;
use Facebook\WebDriver\WebDriverPoint;
/**
* Interface representing basic mouse operations.
*/
class WebDriverCoordinates
{
/**
* @var null
*/
private $onScreen;
/**
* @var callable
*/
private $inViewPort;
/**
* @var callable
*/
private $onPage;
/**
* @var string
*/
private $auxiliary;
/**
* @param null $on_screen
* @param callable $in_view_port
* @param callable $on_page
* @param string $auxiliary
*/
public function __construct($on_screen, callable $in_view_port, callable $on_page, $auxiliary)
{
$this->onScreen = $on_screen;
$this->inViewPort = $in_view_port;
$this->onPage = $on_page;
$this->auxiliary = $auxiliary;
}
/**
* @throws UnsupportedOperationException
* @return WebDriverPoint
*/
public function onScreen()
{
throw new UnsupportedOperationException(
'onScreen is planned but not yet supported by Selenium'
);
}
/**
* @return WebDriverPoint
*/
public function inViewPort()
{
return call_user_func($this->inViewPort);
}
/**
* @return WebDriverPoint
*/
public function onPage()
{
return call_user_func($this->onPage);
}
/**
* @return string The attached object id.
*/
public function getAuxiliary()
{
return $this->auxiliary;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
class WebDriverDoubleClickAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->doubleClick($this->getActionLocation());
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
class WebDriverKeyDownAction extends WebDriverSingleKeyAction
{
public function perform()
{
$this->focusOnElement();
$this->keyboard->pressKey($this->key);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
class WebDriverKeyUpAction extends WebDriverSingleKeyAction
{
public function perform()
{
$this->focusOnElement();
$this->keyboard->releaseKey($this->key);
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverKeyboard;
use Facebook\WebDriver\WebDriverMouse;
/**
* Base class for all keyboard-related actions.
*/
abstract class WebDriverKeysRelatedAction
{
/**
* @var WebDriverKeyboard
*/
protected $keyboard;
/**
* @var WebDriverMouse
*/
protected $mouse;
/**
* @var WebDriverLocatable|null
*/
protected $locationProvider;
/**
* @param WebDriverKeyboard $keyboard
* @param WebDriverMouse $mouse
* @param WebDriverLocatable $location_provider
*/
public function __construct(
WebDriverKeyboard $keyboard,
WebDriverMouse $mouse,
WebDriverLocatable $location_provider = null
) {
$this->keyboard = $keyboard;
$this->mouse = $mouse;
$this->locationProvider = $location_provider;
}
protected function focusOnElement()
{
if ($this->locationProvider) {
$this->mouse->click($this->locationProvider->getCoordinates());
}
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverMouse;
/**
* Base class for all mouse-related actions.
*/
class WebDriverMouseAction
{
/**
* @var WebDriverMouse
*/
protected $mouse;
/**
* @var WebDriverLocatable
*/
protected $locationProvider;
/**
* @param WebDriverMouse $mouse
* @param WebDriverLocatable|null $location_provider
*/
public function __construct(WebDriverMouse $mouse, WebDriverLocatable $location_provider = null)
{
$this->mouse = $mouse;
$this->locationProvider = $location_provider;
}
/**
* @return null|WebDriverCoordinates
*/
protected function getActionLocation()
{
if ($this->locationProvider !== null) {
return $this->locationProvider->getCoordinates();
}
return null;
}
protected function moveToLocation()
{
$this->mouse->mouseMove($this->locationProvider);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\WebDriverAction;
class WebDriverMouseMoveAction extends WebDriverMouseAction implements WebDriverAction
{
public function perform()
{
$this->mouse->mouseMove($this->getActionLocation());
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverAction;
use Facebook\WebDriver\WebDriverMouse;
class WebDriverMoveToOffsetAction extends WebDriverMouseAction implements WebDriverAction
{
/**
* @var int|null
*/
private $xOffset;
/**
* @var int|null
*/
private $yOffset;
/**
* @param WebDriverMouse $mouse
* @param WebDriverLocatable|null $location_provider
* @param int|null $x_offset
* @param int|null $y_offset
*/
public function __construct(
WebDriverMouse $mouse,
WebDriverLocatable $location_provider = null,
$x_offset = null,
$y_offset = null
) {
parent::__construct($mouse, $location_provider);
$this->xOffset = $x_offset;
$this->yOffset = $y_offset;
}
public function perform()
{
$this->mouse->mouseMove(
$this->getActionLocation(),
$this->xOffset,
$this->yOffset
);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverAction;
use Facebook\WebDriver\WebDriverKeyboard;
use Facebook\WebDriver\WebDriverMouse;
class WebDriverSendKeysAction extends WebDriverKeysRelatedAction implements WebDriverAction
{
/**
* @var string
*/
private $keys = '';
/**
* @param WebDriverKeyboard $keyboard
* @param WebDriverMouse $mouse
* @param WebDriverLocatable $location_provider
* @param string $keys
*/
public function __construct(
WebDriverKeyboard $keyboard,
WebDriverMouse $mouse,
WebDriverLocatable $location_provider = null,
$keys = ''
) {
parent::__construct($keyboard, $mouse, $location_provider);
$this->keys = $keys;
}
public function perform()
{
$this->focusOnElement();
$this->keyboard->sendKeys($this->keys);
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Facebook\WebDriver\Interactions\Internal;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverAction;
use Facebook\WebDriver\WebDriverKeyboard;
use Facebook\WebDriver\WebDriverKeys;
use Facebook\WebDriver\WebDriverMouse;
abstract class WebDriverSingleKeyAction extends WebDriverKeysRelatedAction implements WebDriverAction
{
const MODIFIER_KEYS = [
WebDriverKeys::SHIFT,
WebDriverKeys::LEFT_SHIFT,
WebDriverKeys::RIGHT_SHIFT,
WebDriverKeys::CONTROL,
WebDriverKeys::LEFT_CONTROL,
WebDriverKeys::RIGHT_CONTROL,
WebDriverKeys::ALT,
WebDriverKeys::LEFT_ALT,
WebDriverKeys::RIGHT_ALT,
WebDriverKeys::META,
WebDriverKeys::RIGHT_META,
WebDriverKeys::COMMAND,
];
/** @var string */
protected $key;
/**
* @param string $key
* @todo Remove default $key value in next major version (BC)
*/
public function __construct(
WebDriverKeyboard $keyboard,
WebDriverMouse $mouse,
WebDriverLocatable $location_provider = null,
$key = ''
) {
parent::__construct($keyboard, $mouse, $location_provider);
if (!in_array($key, self::MODIFIER_KEYS, true)) {
throw new \InvalidArgumentException(
sprintf(
'keyDown / keyUp actions can only be used for modifier keys, but "%s" was given',
$key
)
);
}
$this->key = $key;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverDoubleTapAction extends WebDriverTouchAction implements WebDriverAction
{
public function perform()
{
$this->touchScreen->doubleTap($this->locationProvider);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverDownAction extends WebDriverTouchAction implements WebDriverAction
{
/**
* @var int
*/
private $x;
/**
* @var int
*/
private $y;
/**
* @param WebDriverTouchScreen $touch_screen
* @param int $x
* @param int $y
*/
public function __construct(WebDriverTouchScreen $touch_screen, $x, $y)
{
$this->x = $x;
$this->y = $y;
parent::__construct($touch_screen);
}
public function perform()
{
$this->touchScreen->down($this->x, $this->y);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverFlickAction extends WebDriverTouchAction implements WebDriverAction
{
/**
* @var int
*/
private $x;
/**
* @var int
*/
private $y;
/**
* @param WebDriverTouchScreen $touch_screen
* @param int $x
* @param int $y
*/
public function __construct(WebDriverTouchScreen $touch_screen, $x, $y)
{
$this->x = $x;
$this->y = $y;
parent::__construct($touch_screen);
}
public function perform()
{
$this->touchScreen->flick($this->x, $this->y);
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
use Facebook\WebDriver\WebDriverElement;
class WebDriverFlickFromElementAction extends WebDriverTouchAction implements WebDriverAction
{
/**
* @var int
*/
private $x;
/**
* @var int
*/
private $y;
/**
* @var int
*/
private $speed;
/**
* @param WebDriverTouchScreen $touch_screen
* @param WebDriverElement $element
* @param int $x
* @param int $y
* @param int $speed
*/
public function __construct(
WebDriverTouchScreen $touch_screen,
WebDriverElement $element,
$x,
$y,
$speed
) {
$this->x = $x;
$this->y = $y;
$this->speed = $speed;
parent::__construct($touch_screen, $element);
}
public function perform()
{
$this->touchScreen->flickFromElement(
$this->locationProvider,
$this->x,
$this->y,
$this->speed
);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverLongPressAction extends WebDriverTouchAction implements WebDriverAction
{
public function perform()
{
$this->touchScreen->longPress($this->locationProvider);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverMoveAction extends WebDriverTouchAction implements WebDriverAction
{
private $x;
private $y;
/**
* @param WebDriverTouchScreen $touch_screen
* @param int $x
* @param int $y
*/
public function __construct(WebDriverTouchScreen $touch_screen, $x, $y)
{
$this->x = $x;
$this->y = $y;
parent::__construct($touch_screen);
}
public function perform()
{
$this->touchScreen->move($this->x, $this->y);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverScrollAction extends WebDriverTouchAction implements WebDriverAction
{
private $x;
private $y;
/**
* @param WebDriverTouchScreen $touch_screen
* @param int $x
* @param int $y
*/
public function __construct(WebDriverTouchScreen $touch_screen, $x, $y)
{
$this->x = $x;
$this->y = $y;
parent::__construct($touch_screen);
}
public function perform()
{
$this->touchScreen->scroll($this->x, $this->y);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
use Facebook\WebDriver\WebDriverElement;
class WebDriverScrollFromElementAction extends WebDriverTouchAction implements WebDriverAction
{
private $x;
private $y;
/**
* @param WebDriverTouchScreen $touch_screen
* @param WebDriverElement $element
* @param int $x
* @param int $y
*/
public function __construct(
WebDriverTouchScreen $touch_screen,
WebDriverElement $element,
$x,
$y
) {
$this->x = $x;
$this->y = $y;
parent::__construct($touch_screen, $element);
}
public function perform()
{
$this->touchScreen->scrollFromElement(
$this->locationProvider,
$this->x,
$this->y
);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverAction;
class WebDriverTapAction extends WebDriverTouchAction implements WebDriverAction
{
public function perform()
{
$this->touchScreen->tap($this->locationProvider);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\Interactions\Internal\WebDriverCoordinates;
use Facebook\WebDriver\Internal\WebDriverLocatable;
/**
* Base class for all touch-related actions.
*/
abstract class WebDriverTouchAction
{
/**
* @var WebDriverTouchScreen
*/
protected $touchScreen;
/**
* @var WebDriverLocatable
*/
protected $locationProvider;
/**
* @param WebDriverTouchScreen $touch_screen
* @param WebDriverLocatable $location_provider
*/
public function __construct(
WebDriverTouchScreen $touch_screen,
WebDriverLocatable $location_provider = null
) {
$this->touchScreen = $touch_screen;
$this->locationProvider = $location_provider;
}
/**
* @return null|WebDriverCoordinates
*/
protected function getActionLocation()
{
return $this->locationProvider !== null
? $this->locationProvider->getCoordinates() : null;
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Facebook\WebDriver\Interactions\Touch;
use Facebook\WebDriver\WebDriverElement;
/**
* Interface representing touch screen operations.
*/
interface WebDriverTouchScreen
{
/**
* Single tap on the touch enabled device.
*
* @param WebDriverElement $element
* @return $this
*/
public function tap(WebDriverElement $element);
/**
* Double tap on the touch screen using finger motion events.
*
* @param WebDriverElement $element
* @return $this
*/
public function doubleTap(WebDriverElement $element);
/**
* Finger down on the screen.
*
* @param int $x
* @param int $y
* @return $this
*/
public function down($x, $y);
/**
* Flick on the touch screen using finger motion events. Use this flick
* command if you don't care where the flick starts on the screen.
*
* @param int $xspeed
* @param int $yspeed
* @return $this
*/
public function flick($xspeed, $yspeed);
/**
* Flick on the touch screen using finger motion events.
* This flickcommand starts at a particular screen location.
*
* @param WebDriverElement $element
* @param int $xoffset
* @param int $yoffset
* @param int $speed
* @return $this
*/
public function flickFromElement(
WebDriverElement $element,
$xoffset,
$yoffset,
$speed
);
/**
* Long press on the touch screen using finger motion events.
*
* @param WebDriverElement $element
* @return $this
*/
public function longPress(WebDriverElement $element);
/**
* Finger move on the screen.
*
* @param int $x
* @param int $y
* @return $this
*/
public function move($x, $y);
/**
* Scroll on the touch screen using finger based motion events. Use this
* command if you don't care where the scroll starts on the screen.
*
* @param int $xoffset
* @param int $yoffset
* @return $this
*/
public function scroll($xoffset, $yoffset);
/**
* Scroll on the touch screen using finger based motion events. Use this
* command to start scrolling at a particular screen location.
*
* @param WebDriverElement $element
* @param int $xoffset
* @param int $yoffset
* @return $this
*/
public function scrollFromElement(
WebDriverElement $element,
$xoffset,
$yoffset
);
/**
* Finger up on the screen.
*
* @param int $x
* @param int $y
* @return $this
*/
public function up($x, $y);
}

View File

@@ -0,0 +1,268 @@
<?php
namespace Facebook\WebDriver\Interactions;
use Facebook\WebDriver\Interactions\Internal\WebDriverButtonReleaseAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverClickAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverClickAndHoldAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverContextClickAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverDoubleClickAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverKeyDownAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverKeyUpAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverMouseMoveAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverMoveToOffsetAction;
use Facebook\WebDriver\Interactions\Internal\WebDriverSendKeysAction;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverHasInputDevices;
/**
* WebDriver action builder. It implements the builder pattern.
*/
class WebDriverActions
{
protected $driver;
protected $keyboard;
protected $mouse;
protected $action;
/**
* @param WebDriverHasInputDevices $driver
*/
public function __construct(WebDriverHasInputDevices $driver)
{
$this->driver = $driver;
$this->keyboard = $driver->getKeyboard();
$this->mouse = $driver->getMouse();
$this->action = new WebDriverCompositeAction();
}
/**
* A convenience method for performing the actions without calling build().
*/
public function perform()
{
$this->action->perform();
}
/**
* Mouse click.
* If $element is provided, move to the middle of the element first.
*
* @param WebDriverElement $element
* @return WebDriverActions
*/
public function click(WebDriverElement $element = null)
{
$this->action->addAction(
new WebDriverClickAction($this->mouse, $element)
);
return $this;
}
/**
* Mouse click and hold.
* If $element is provided, move to the middle of the element first.
*
* @param WebDriverElement $element
* @return WebDriverActions
*/
public function clickAndHold(WebDriverElement $element = null)
{
$this->action->addAction(
new WebDriverClickAndHoldAction($this->mouse, $element)
);
return $this;
}
/**
* Context-click (right click).
* If $element is provided, move to the middle of the element first.
*
* @param WebDriverElement $element
* @return WebDriverActions
*/
public function contextClick(WebDriverElement $element = null)
{
$this->action->addAction(
new WebDriverContextClickAction($this->mouse, $element)
);
return $this;
}
/**
* Double click.
* If $element is provided, move to the middle of the element first.
*
* @param WebDriverElement $element
* @return WebDriverActions
*/
public function doubleClick(WebDriverElement $element = null)
{
$this->action->addAction(
new WebDriverDoubleClickAction($this->mouse, $element)
);
return $this;
}
/**
* Drag and drop from $source to $target.
*
* @param WebDriverElement $source
* @param WebDriverElement $target
* @return WebDriverActions
*/
public function dragAndDrop(WebDriverElement $source, WebDriverElement $target)
{
$this->action->addAction(
new WebDriverClickAndHoldAction($this->mouse, $source)
);
$this->action->addAction(
new WebDriverMouseMoveAction($this->mouse, $target)
);
$this->action->addAction(
new WebDriverButtonReleaseAction($this->mouse, $target)
);
return $this;
}
/**
* Drag $source and drop by offset ($x_offset, $y_offset).
*
* @param WebDriverElement $source
* @param int $x_offset
* @param int $y_offset
* @return WebDriverActions
*/
public function dragAndDropBy(WebDriverElement $source, $x_offset, $y_offset)
{
$this->action->addAction(
new WebDriverClickAndHoldAction($this->mouse, $source)
);
$this->action->addAction(
new WebDriverMoveToOffsetAction($this->mouse, null, $x_offset, $y_offset)
);
$this->action->addAction(
new WebDriverButtonReleaseAction($this->mouse, null)
);
return $this;
}
/**
* Mouse move by offset.
*
* @param int $x_offset
* @param int $y_offset
* @return WebDriverActions
*/
public function moveByOffset($x_offset, $y_offset)
{
$this->action->addAction(
new WebDriverMoveToOffsetAction($this->mouse, null, $x_offset, $y_offset)
);
return $this;
}
/**
* Move to the middle of the given WebDriverElement.
* Extra shift, calculated from the top-left corner of the element, can be set by passing $x_offset and $y_offset
* parameters.
*
* @param WebDriverElement $element
* @param int $x_offset
* @param int $y_offset
* @return WebDriverActions
*/
public function moveToElement(WebDriverElement $element, $x_offset = null, $y_offset = null)
{
$this->action->addAction(new WebDriverMoveToOffsetAction(
$this->mouse,
$element,
$x_offset,
$y_offset
));
return $this;
}
/**
* Release the mouse button.
* If $element is provided, move to the middle of the element first.
*
* @param WebDriverElement $element
* @return WebDriverActions
*/
public function release(WebDriverElement $element = null)
{
$this->action->addAction(
new WebDriverButtonReleaseAction($this->mouse, $element)
);
return $this;
}
/**
* Press a key on keyboard.
* If $element is provided, focus on that element first.
*
* @see WebDriverKeys for special keys like CONTROL, ALT, etc.
* @param WebDriverElement $element
* @param string $key
* @return WebDriverActions
*/
public function keyDown(WebDriverElement $element = null, $key = null)
{
$this->action->addAction(
new WebDriverKeyDownAction($this->keyboard, $this->mouse, $element, $key)
);
return $this;
}
/**
* Release a key on keyboard.
* If $element is provided, focus on that element first.
*
* @see WebDriverKeys for special keys like CONTROL, ALT, etc.
* @param WebDriverElement $element
* @param string $key
* @return WebDriverActions
*/
public function keyUp(WebDriverElement $element = null, $key = null)
{
$this->action->addAction(
new WebDriverKeyUpAction($this->keyboard, $this->mouse, $element, $key)
);
return $this;
}
/**
* Send keys by keyboard.
* If $element is provided, focus on that element first (using single mouse click).
*
* @see WebDriverKeys for special keys like CONTROL, ALT, etc.
* @param WebDriverElement $element
* @param string $keys
* @return WebDriverActions
*/
public function sendKeys(WebDriverElement $element = null, $keys = null)
{
$this->action->addAction(
new WebDriverSendKeysAction(
$this->keyboard,
$this->mouse,
$element,
$keys
)
);
return $this;
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Facebook\WebDriver\Interactions;
use Facebook\WebDriver\WebDriverAction;
/**
* An action for aggregating actions and triggering all of them afterwards.
*/
class WebDriverCompositeAction implements WebDriverAction
{
/**
* @var WebDriverAction[]
*/
private $actions = [];
/**
* Add an WebDriverAction to the sequence.
*
* @param WebDriverAction $action
* @return WebDriverCompositeAction The current instance.
*/
public function addAction(WebDriverAction $action)
{
$this->actions[] = $action;
return $this;
}
/**
* Get the number of actions in the sequence.
*
* @return int The number of actions.
*/
public function getNumberOfActions()
{
return count($this->actions);
}
/**
* Perform the sequence of actions.
*/
public function perform()
{
foreach ($this->actions as $action) {
$action->perform();
}
}
}

View File

@@ -0,0 +1,180 @@
<?php
namespace Facebook\WebDriver\Interactions;
use Facebook\WebDriver\Interactions\Touch\WebDriverDoubleTapAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverDownAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverFlickAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverFlickFromElementAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverLongPressAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverMoveAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverScrollAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverScrollFromElementAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverTapAction;
use Facebook\WebDriver\Interactions\Touch\WebDriverTouchScreen;
use Facebook\WebDriver\WebDriver;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverUpAction;
/**
* WebDriver action builder for touch events
*/
class WebDriverTouchActions extends WebDriverActions
{
/**
* @var WebDriverTouchScreen
*/
protected $touchScreen;
public function __construct(WebDriver $driver)
{
parent::__construct($driver);
$this->touchScreen = $driver->getTouch();
}
/**
* @param WebDriverElement $element
* @return WebDriverTouchActions
*/
public function tap(WebDriverElement $element)
{
$this->action->addAction(
new WebDriverTapAction($this->touchScreen, $element)
);
return $this;
}
/**
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function down($x, $y)
{
$this->action->addAction(
new WebDriverDownAction($this->touchScreen, $x, $y)
);
return $this;
}
/**
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function up($x, $y)
{
$this->action->addAction(
new WebDriverUpAction($this->touchScreen, $x, $y)
);
return $this;
}
/**
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function move($x, $y)
{
$this->action->addAction(
new WebDriverMoveAction($this->touchScreen, $x, $y)
);
return $this;
}
/**
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function scroll($x, $y)
{
$this->action->addAction(
new WebDriverScrollAction($this->touchScreen, $x, $y)
);
return $this;
}
/**
* @param WebDriverElement $element
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function scrollFromElement(WebDriverElement $element, $x, $y)
{
$this->action->addAction(
new WebDriverScrollFromElementAction($this->touchScreen, $element, $x, $y)
);
return $this;
}
/**
* @param WebDriverElement $element
* @return WebDriverTouchActions
*/
public function doubleTap(WebDriverElement $element)
{
$this->action->addAction(
new WebDriverDoubleTapAction($this->touchScreen, $element)
);
return $this;
}
/**
* @param WebDriverElement $element
* @return WebDriverTouchActions
*/
public function longPress(WebDriverElement $element)
{
$this->action->addAction(
new WebDriverLongPressAction($this->touchScreen, $element)
);
return $this;
}
/**
* @param int $x
* @param int $y
* @return WebDriverTouchActions
*/
public function flick($x, $y)
{
$this->action->addAction(
new WebDriverFlickAction($this->touchScreen, $x, $y)
);
return $this;
}
/**
* @param WebDriverElement $element
* @param int $x
* @param int $y
* @param int $speed
* @return WebDriverTouchActions
*/
public function flickFromElement(WebDriverElement $element, $x, $y, $speed)
{
$this->action->addAction(
new WebDriverFlickFromElementAction(
$this->touchScreen,
$element,
$x,
$y,
$speed
)
);
return $this;
}
}