vendor/php-webdriver/webdriver/lib/Firefox/FirefoxDriver.php line 10

Open in your IDE?
  1. <?php
  2. namespace Facebook\WebDriver\Firefox;
  3. use Facebook\WebDriver\Local\LocalWebDriver;
  4. use Facebook\WebDriver\Remote\DesiredCapabilities;
  5. use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
  6. use Facebook\WebDriver\Remote\WebDriverCommand;
  7. class FirefoxDriver extends LocalWebDriver
  8. {
  9.     const PROFILE 'firefox_profile';
  10.     /**
  11.      * Creates a new FirefoxDriver using default configuration.
  12.      * This includes starting a new geckodriver process  each time this method is called. However this may be
  13.      * unnecessary overhead - instead, you can start the process once using FirefoxDriverService and pass
  14.      * this instance to startUsingDriverService() method.
  15.      *
  16.      * @return static
  17.      */
  18.     public static function start(DesiredCapabilities $capabilities null)
  19.     {
  20.         $service FirefoxDriverService::createDefaultService();
  21.         return static::startUsingDriverService($service$capabilities);
  22.     }
  23.     /**
  24.      * Creates a new FirefoxDriver using given FirefoxDriverService.
  25.      * This is usable when you for example don't want to start new geckodriver process for each individual test
  26.      * and want to reuse the already started geckodriver, which will lower the overhead associated with spinning up
  27.      * a new process.
  28.      *
  29.      * @return static
  30.      */
  31.     public static function startUsingDriverService(
  32.         FirefoxDriverService $service,
  33.         DesiredCapabilities $capabilities null
  34.     ) {
  35.         if ($capabilities === null) {
  36.             $capabilities DesiredCapabilities::firefox();
  37.         }
  38.         $executor = new DriverCommandExecutor($service);
  39.         $newSessionCommand WebDriverCommand::newSession(
  40.             [
  41.                 'capabilities' => [
  42.                     'firstMatch' => [(object) $capabilities->toW3cCompatibleArray()],
  43.                 ],
  44.             ]
  45.         );
  46.         $response $executor->execute($newSessionCommand);
  47.         $returnedCapabilities DesiredCapabilities::createFromW3cCapabilities($response->getValue()['capabilities']);
  48.         $sessionId $response->getSessionID();
  49.         return new static($executor$sessionId$returnedCapabilitiestrue);
  50.     }
  51. }