1<?php 2 3namespace Facebook\WebDriver\Interactions\Internal; 4 5use Facebook\WebDriver\Internal\WebDriverLocatable; 6use Facebook\WebDriver\WebDriverKeyboard; 7use Facebook\WebDriver\WebDriverMouse; 8 9/** 10 * Base class for all keyboard-related actions. 11 */ 12abstract class WebDriverKeysRelatedAction 13{ 14 /** 15 * @var WebDriverKeyboard 16 */ 17 protected $keyboard; 18 /** 19 * @var WebDriverMouse 20 */ 21 protected $mouse; 22 /** 23 * @var WebDriverLocatable|null 24 */ 25 protected $locationProvider; 26 27 /** 28 * @param WebDriverKeyboard $keyboard 29 * @param WebDriverMouse $mouse 30 * @param WebDriverLocatable $location_provider 31 */ 32 public function __construct( 33 WebDriverKeyboard $keyboard, 34 WebDriverMouse $mouse, 35 WebDriverLocatable $location_provider = null 36 ) { 37 $this->keyboard = $keyboard; 38 $this->mouse = $mouse; 39 $this->locationProvider = $location_provider; 40 } 41 42 protected function focusOnElement() 43 { 44 if ($this->locationProvider) { 45 $this->mouse->click($this->locationProvider->getCoordinates()); 46 } 47 } 48} 49