class BasePhantomJSDriver in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/jcalderonzumba/mink-phantomjs-driver/src/BasePhantomJSDriver.php \Zumba\Mink\Driver\BasePhantomJSDriver
Class BasePhantomJSDriver @package Zumba\Mink\Driver
Hierarchy
- class \Behat\Mink\Driver\CoreDriver implements DriverInterface- class \Zumba\Mink\Driver\BasePhantomJSDriver
 
Expanded class hierarchy of BasePhantomJSDriver
File
- vendor/jcalderonzumba/ mink-phantomjs-driver/ src/ BasePhantomJSDriver.php, line 14 
Namespace
Zumba\Mink\DriverView source
class BasePhantomJSDriver extends CoreDriver {
  /** @var  Session */
  protected $session;
  /** @var  Browser */
  protected $browser;
  /** @var  string */
  protected $phantomHost;
  /** @var  \Twig_Loader_Filesystem */
  protected $templateLoader;
  /** @var  \Twig_Environment */
  protected $templateEnv;
  /**
   * Instantiates the driver
   * @param string $phantomHost browser "api" oriented host
   * @param string $templateCache where we are going to store the templates cache
   */
  public function __construct($phantomHost, $templateCache = null) {
    $this->phantomHost = $phantomHost;
    $this->browser = new Browser($phantomHost);
    $this->templateLoader = new \Twig_Loader_Filesystem(realpath(__DIR__ . '/Resources/Script'));
    $this->templateEnv = new \Twig_Environment($this->templateLoader, array(
      'cache' => $this
        ->templateCacheSetup($templateCache),
      'strict_variables' => true,
    ));
  }
  /**
   * Sets up the cache template location for the scripts we are going to create with the driver
   * @param $templateCache
   * @return string
   * @throws DriverException
   */
  protected function templateCacheSetup($templateCache) {
    $cacheDir = $templateCache;
    if ($templateCache === null) {
      $cacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "jcalderonzumba" . DIRECTORY_SEPARATOR . "phantomjs";
      if (!file_exists($cacheDir)) {
        mkdir($cacheDir, 0777, true);
      }
    }
    if (!file_exists($cacheDir)) {
      throw new DriverException("Template cache {$cacheDir} directory does not exist");
    }
    return $cacheDir;
  }
  /**
   * Helper to find a node element given an xpath
   * @param string $xpath
   * @param int    $max
   * @returns int
   * @throws DriverException
   */
  protected function findElement($xpath, $max = 1) {
    $elements = $this->browser
      ->find("xpath", $xpath);
    if (!isset($elements["page_id"]) || !isset($elements["ids"]) || count($elements["ids"]) !== $max) {
      throw new DriverException("Failed to get elements with given {$xpath}");
    }
    return $elements;
  }
  /**
   * {@inheritdoc}
   * @param Session $session
   */
  public function setSession(Session $session) {
    $this->session = $session;
  }
  /**
   * @return Browser
   */
  public function getBrowser() {
    return $this->browser;
  }
  /**
   * @return \Twig_Environment
   */
  public function getTemplateEnv() {
    return $this->templateEnv;
  }
  /**
   * Returns a javascript script via twig template engine
   * @param $templateName
   * @param $viewData
   * @return string
   */
  public function javascriptTemplateRender($templateName, $viewData) {
    /** @var $templateEngine \Twig_Environment */
    $templateEngine = $this
      ->getTemplateEnv();
    return $templateEngine
      ->render($templateName, $viewData);
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| BasePhantomJSDriver:: | protected | property | @var Browser | |
| BasePhantomJSDriver:: | protected | property | @var string | |
| BasePhantomJSDriver:: | protected | property | @var  Session Overrides CoreDriver:: | |
| BasePhantomJSDriver:: | protected | property | @var \Twig_Environment | |
| BasePhantomJSDriver:: | protected | property | @var \Twig_Loader_Filesystem | |
| BasePhantomJSDriver:: | protected | function | Helper to find a node element given an xpath | |
| BasePhantomJSDriver:: | public | function | ||
| BasePhantomJSDriver:: | public | function | ||
| BasePhantomJSDriver:: | public | function | Returns a javascript script via twig template engine | |
| BasePhantomJSDriver:: | public | function | Overrides CoreDriver:: | |
| BasePhantomJSDriver:: | protected | function | Sets up the cache template location for the scripts we are going to create with the driver | |
| BasePhantomJSDriver:: | public | function | Instantiates the driver | |
| CoreDriver:: | public | function | Attaches file path to file field located by it's XPath query. Overrides DriverInterface:: | 2 | 
| CoreDriver:: | public | function | Moves browser backward 1 page. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Removes focus from element. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Checks checkbox by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Clicks button or link located by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Double-clicks button or link located by it's XPath query. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Drag one element onto another. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Evaluates JS script. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Executes JS script. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Finds elements with specified XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | protected | function | Finds elements with specified XPath query. | 1 | 
| CoreDriver:: | public | function | Brings focus to element. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Moves browser forward 1 page. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns element's attribute by it's XPath query. Overrides DriverInterface:: | 2 | 
| CoreDriver:: | public | function | Returns last response content. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns cookie by name. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns current URL address. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns element's inner html by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns element's outer html by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns last response headers. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Capture a screenshot of the current window. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Returns last response status code. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns element's tag name by it's XPath query. Overrides DriverInterface:: | 2 | 
| CoreDriver:: | public | function | Returns element's text by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Returns element's value by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Return the name of the currently active window. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Return the names of all open windows. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Checks whether checkbox or radio button located by it's XPath query is checked. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Checks whether select option, located by it's XPath query, is selected. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Checks whether driver is started. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Checks whether element visible located by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Pressed down specific keyboard key. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Presses specific keyboard key. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Pressed up specific keyboard key. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Maximizes the window if it is not maximized already. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Simulates a mouse over on the element. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Reloads current page. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Resets driver state. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Set the dimensions of the window. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Right-clicks button or link located by it's XPath query. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Selects option from select field or value in radio group located by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Sets HTTP Basic authentication parameters. Overrides DriverInterface:: | 2 | 
| CoreDriver:: | public | function | Sets cookie. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Sets specific request header on client. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Sets element's value by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Starts driver. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Stops driver. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Submits the form. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Switches to specific iFrame. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Switches to specific browser window. Overrides DriverInterface:: | |
| CoreDriver:: | public | function | Unchecks checkbox by it's XPath query. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Visit specified URL. Overrides DriverInterface:: | 1 | 
| CoreDriver:: | public | function | Waits some time or until JS condition turns true. Overrides DriverInterface:: | 
