Skip to content

Commit

Permalink
Foo
Browse files Browse the repository at this point in the history
  • Loading branch information
RLovelett committed Dec 27, 2018
1 parent 2a98e31 commit e6e8aac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,25 @@ var Safari = function(baseBrowserDecorator, args, logger) {
// TODO: It would be nice if this was configurable
const SLEEP_DURATION = 500;

const webDriverConfig = {
browserName: 'safari',
allowW3C: true
};

function attachKarma(error) {
attempts += 1;
if (error && error.code === 'ECONNREFUSED' && attempts === 1) {
log.debug('attachKarma ' + attempts + ' of ' + MAX_ATTEMPTS);
log.debug(self._getCommand() + ' is not running.');
log.debug('Attempting to start ' + self._getCommand() + ' ' + self._getOptions(url).join(' '));
superStart(url);
self.driver.init({ browserName: 'safari', allowW3C: true }, attachKarma);
self.driver.init(webDriverConfig, attachKarma);
} else if (error && error.code === 'ECONNREFUSED' && attempts <= MAX_ATTEMPTS) {
log.debug('attachKarma ' + attempts + ' of ' + MAX_ATTEMPTS);
log.debug('Going to give the driver time to start-up. Sleeping for ' + SLEEP_DURATION + 'ms.');
setTimeout(function() {
log.debug('Awoke to retry.');
self.driver.init({ browserName: 'safari', allowW3C: true }, attachKarma);
self.driver.init(webDriverConfig, attachKarma);
}, SLEEP_DURATION);
} else if (error) {
log.error('Could not connect to Safari.');
Expand All @@ -85,7 +90,7 @@ var Safari = function(baseBrowserDecorator, args, logger) {
}
}

self.driver.init({ browserName: 'safari', allowW3C: true }, attachKarma);
self.driver.init(webDriverConfig, attachKarma);
});

this.on('kill', (done) => {
Expand Down

0 comments on commit e6e8aac

Please sign in to comment.