Skip to content

Commit

Permalink
Merge pull request #1403 from pablopaul/2.0
Browse files Browse the repository at this point in the history
Load firefox profile from suite config.
  • Loading branch information
DavertMik committed Sep 27, 2014
2 parents 002ea88 + 99174e9 commit 998a618
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
* wait: 10
* capabilities:
* unexpectedAlertBehaviour: 'accept'
* firefox_profile: '/Users/paul/Library/Application Support/Firefox/Profiles/codeception-profile.zip.b64'
*
* ## Migration Guide (Selenium2 -> WebDriver)
*
Expand Down Expand Up @@ -94,6 +95,7 @@ public function _initialize()
$this->wd_host = sprintf('http://%s:%s/wd/hub', $this->config['host'], $this->config['port']);
$this->capabilities = $this->config['capabilities'];
$this->capabilities[\WebDriverCapabilityType::BROWSER_NAME] = $this->config['browser'];
$this->firefoxProfile();
$this->webDriver = \RemoteWebDriver::create($this->wd_host, $this->capabilities);
$this->webDriver->manage()->timeouts()->implicitlyWait($this->config['wait']);
$this->initialWindowSize();
Expand All @@ -106,6 +108,22 @@ public function _before(\Codeception\TestCase $test)
}
}

protected function firefoxProfile()
{

if (array_key_exists('firefox_profile', $this->config['capabilities'])) {

$firefox_profile = $this->config['capabilities']['firefox_profile'];

if (file_exists($firefox_profile) === false) {
throw new \Codeception\Exception\ModuleConfig(__CLASS__, "Firefox profile does not exists under given path " . $firefox_profile);
}

// Set firefox profile as capability
$this->capabilities['firefox_profile'] = file_get_contents($firefox_profile);
}
}

protected function initialWindowSize()
{
if ($this->config['window_size'] == 'maximize') {
Expand Down

0 comments on commit 998a618

Please sign in to comment.