Extract Selenium JAR url from Google APIs XML.
authorJetha Chan <jethachan@gmail.com>
Mon, 22 Feb 2016 07:36:11 +0000 (16:36 +0900)
committerFrederic Massart <fred@moodle.com>
Mon, 22 Feb 2016 11:32:23 +0000 (19:32 +0800)
mdk/commands/behat.py

index 2f3b3e6..2845d0f 100644 (file)
@@ -189,17 +189,19 @@ class BehatCommand(Command):
             seleniumPath = args.selenium
         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/')
+            seleniumStorageUrl = 'https://selenium-release.storage.googleapis.com/'
+            url = urllib.urlopen(seleniumStorageUrl)
             content = url.read()
-            selenium = re.search(r'http:[a-z0-9/._-]+selenium-server-standalone-[0-9.]+\.jar', content, re.I)
-            if selenium:
-                logging.info('Downloading Selenium from %s' % (selenium.group(0)))
+            matches = sorted(re.findall(r'[a-z0-9/._-]+selenium-server-standalone-[0-9.]+\.jar', content, re.I))
+            if len(matches) > 0:
+                seleniumUrl = seleniumStorageUrl + matches[-1]
+                logging.info('Downloading Selenium from %s' % seleniumUrl)
                 if (logging.getLogger().level <= logging.INFO):
-                    urllib.urlretrieve(selenium.group(0), seleniumPath, downloadProcessHook)
+                    urllib.urlretrieve(seleniumUrl, seleniumPath, downloadProcessHook)
                     # Force a new line after the hook display
                     logging.info('')
                 else:
-                    urllib.urlretrieve(selenium.group(0), seleniumPath)
+                    urllib.urlretrieve(seleniumUrl, seleniumPath)
             else:
                 logging.warning('Could not locate Selenium server to download')