Skip to content

Commit

Permalink
Wrap Selenium in xvfb-run if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Sep 4, 2014
1 parent 0e1c290 commit 386c134
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mdk/commands/behat.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ class BehatCommand(Command):
'help': 'outputs the output from selenium in the same window'
}
),
(
['-x', '--xvfb'],
{
'action': 'store_true',
'dest': 'xvfb',
'help': 'Use XVFB when starting selenium'
}
),
(
['-X', '--no-xvfb'],
{
'action': 'store_true',
'dest': 'noxvfb',
'help': 'Do not use XVFB when starting selenium'
}
),
(
['name'],
{
Expand Down Expand Up @@ -223,6 +239,14 @@ def run(self, args):
if seleniumPath:
seleniumCommand = '%s -jar %s' % (self.C.get('java'), seleniumPath)

usexvfb = ((self.C.get('xvfb') and not args.noxvfb) or
(not self.C.get('xvfb') and args.xvfb and not args.noxvfb))
if usexvfb:
xvfbPath = self.C.get('xvfb-run')
seleniumCommand = '%s %s' % (xvfbPath, seleniumCommand)
if not os.path.isfile(xvfbPath):
raise Exception('xvfb-run command could not be found in the specified location %s' % (xvfbPath));

olderThan27 = M.branch_compare(27, '<')

if args.run:
Expand Down
6 changes: 6 additions & 0 deletions mdk/config-dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@
"lessc": "/usr/local/bin/lessc",
// Path to shifter
"shifter": "/usr/bin/shifter",
// Path to xvfb-run
"xvfb-run": "/usr/bin/xvfb-run",

// Whether to use xvfb by default
"xvfb": false,

// Path to your favourite editor. Set to null to guess it from the System environment.
"editor": null,

Expand Down

0 comments on commit 386c134

Please sign in to comment.