Behat option to force the download of Selenium
authorFrederic Massart <fred@moodle.com>
Mon, 9 Sep 2013 08:13:01 +0000 (16:13 +0800)
committerFrederic Massart <fred@moodle.com>
Mon, 9 Sep 2013 08:13:01 +0000 (16:13 +0800)
extra/bash_completion
lib/commands/behat.py

index 1417dd9..262a567 100644 (file)
@@ -97,7 +97,7 @@ function _mdk() {
                     OPTS="$(compgen -A file $CUR)"
                     compopt -o nospace
                 else
-                    OPTS="--run --disable --feature --switch-completely --no-javascript --selenium --selenium-verbose --tags"
+                    OPTS="--run --disable --feature --switch-completely --no-javascript --selenium --selenium-download --selenium-verbose --tags"
                     OPTS="$OPTS $(_list_instances)"
                 fi
                 ;;
index 4191f2c..7d759b4 100644 (file)
@@ -89,6 +89,14 @@ class BehatCommand(Command):
             }
         ),
         (
+            ['--selenium-download'],
+            {
+                'action': 'store_true',
+                'dest': 'seleniumforcedl',
+                'help': 'force the download of the latest Selenium to the cache'
+            }
+        ),
+        (
             ['--selenium-verbose'],
             {
                 'action': 'store_true',
@@ -155,7 +163,7 @@ class BehatCommand(Command):
         seleniumPath = os.path.expanduser(os.path.join(self.C.get('dirs.mdk'), 'selenium.jar'))
         if args.selenium:
             seleniumPath = args.selenium
-        elif not nojavascript and not os.path.isfile(seleniumPath):
+        elif args.seleniumforcedl or (not nojavascript and not os.path.isfile(seleniumPath)):
             logging.info('Attempting to find a download for Selenium')
             url = urllib.urlopen('http://docs.seleniumhq.org/download/')
             content = url.read()
@@ -166,7 +174,7 @@ class BehatCommand(Command):
             else:
                 logging.warning('Could not locate Selenium server to download')
 
-        if not os.path.isfile(seleniumPath):
+        if not nojavascript and not os.path.isfile(seleniumPath):
             raise Exception('Selenium file %s does not exist')
 
         # Run cli