Пример #1
0
 public function __construct($config = [])
 {
     parent::__construct($config);
     $getAllSessions = RemoteWebDriver::getAllSessions($this->host);
     if ($this->sessionId && ArrayHelper::inMultiArray($this->sessionId, $getAllSessions, 'id')) {
         $this->driver = RemoteWebDriver::createBySessionID($this->sessionId, $this->host);
     } else {
         $desired_capabilities = DesiredCapabilities::firefox();
         $fp = new FirefoxProfile();
         $desired_capabilities->setCapability(WebDriverCapabilityType::NATIVE_EVENTS, true);
         if (isset($this->proxy['ip'])) {
             $this->proxy['port'] = ArrayHelper::getValue($this->proxy, 'port');
             $fp->setPreference('network.proxy.ssl_port', $this->proxy['port']);
             $fp->setPreference('network.proxy.ssl', $this->proxy['ip']);
             $fp->setPreference('network.proxy.http_port', $this->proxy['port']);
             $fp->setPreference('network.proxy.http', $this->proxy['ip']);
             $fp->setPreference('network.proxy.type', 1);
         }
         $desired_capabilities->setCapability(FirefoxDriver::PROFILE, $fp);
         $this->driver = RemoteWebDriver::create($this->host, $desired_capabilities, 600000, 600000);
         $this->sessionId = $this->driver->getSessionID();
     }
 }
Пример #2
0
 /**
  * @return DesiredCapabilities
  */
 public static function firefox()
 {
     $caps = new DesiredCapabilities(array(WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::FIREFOX, WebDriverCapabilityType::PLATFORM => WebDriverPlatform::ANY));
     // disable the "Reader View" help tooltip, which can hide elements in the window.document
     $profile = new FirefoxProfile();
     $profile->setPreference('reader.parse-on-load.enabled', false);
     $caps->setCapability(FirefoxDriver::PROFILE, $profile);
     return $caps;
 }