def _Run(java_tests_src_dir, test_filter, chromedriver_path, chrome_path, android_package, verbose, debug): """Run the WebDriver Java tests and return the test results. Args: java_tests_src_dir: the java test source code directory. test_filter: the filter to use when choosing tests to run. Format is same as Google C++ Test format. chromedriver_path: path to ChromeDriver exe. chrome_path: path to Chrome exe. android_package: name of Chrome's Android package. verbose: whether the output should be verbose. debug: whether the tests should wait until attached by a debugger. Returns: A list of |TestResult|s. """ test_dir = util.MakeTempDir() keystore_path = ('java', 'client', 'test', 'keystore') required_dirs = [keystore_path[:-1], ('javascript',), ('third_party', 'closure', 'goog'), ('third_party', 'js')] for required_dir in required_dirs: os.makedirs(os.path.join(test_dir, *required_dir)) test_jar = 'test-standalone.jar' class_path = test_jar shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'), os.path.join(test_dir, *keystore_path)) util.Unzip(os.path.join(java_tests_src_dir, 'common.zip'), test_dir) shutil.copyfile(os.path.join(java_tests_src_dir, test_jar), os.path.join(test_dir, test_jar)) sys_props = ['selenium.browser=chrome', 'webdriver.chrome.driver=' + os.path.abspath(chromedriver_path)] if chrome_path is not None: sys_props += ['webdriver.chrome.binary=' + os.path.abspath(chrome_path)] if android_package is not None: sys_props += ['webdriver.chrome.android_package=' + android_package] if test_filter: # Test jar actually takes a regex. Convert from glob. test_filter = test_filter.replace('*', '.*') sys_props += ['filter=' + test_filter] jvm_args = [] if debug: jvm_args += ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,' 'address=33081'] # Unpack the sources into the test directory and add to the class path # for ease of debugging, particularly with jdb. util.Unzip(os.path.join(java_tests_src_dir, 'test-nodeps-srcs.jar'), test_dir) class_path += ':' + test_dir return _RunAntTest( test_dir, 'org.openqa.selenium.chrome.ChromeDriverTests', class_path, sys_props, jvm_args, verbose)
def DownloadChrome(revision, dest_dir, site=Site.CONTINUOUS): """Downloads the packaged Chrome from the archive to the given directory. Args: revision: the revision of Chrome to download. dest_dir: the directory to download Chrome to. site: the archive site to download from, default to the continuous one. Returns: The path to the unzipped Chrome binary. """ def GetZipName(): if util.IsWindows(): return 'chrome-win32' elif util.IsMac(): return 'chrome-mac' elif util.IsLinux(): return 'chrome-linux' def GetChromePathFromPackage(): if util.IsWindows(): return 'chrome.exe' elif util.IsMac(): return 'Chromium.app/Contents/MacOS/Chromium' elif util.IsLinux(): return 'chrome' zip_path = os.path.join(dest_dir, 'chrome-%s.zip' % revision) if not os.path.exists(zip_path): url = site + '/%s/%s/%s.zip' % (_GetDownloadPlatform(), revision, GetZipName()) print 'Downloading', url, '...' urllib.urlretrieve(url, zip_path) util.Unzip(zip_path, dest_dir) return os.path.join(dest_dir, GetZipName(), GetChromePathFromPackage())
def _DownloadPrebuilts(): """Downloads the most recent prebuilts from google storage.""" util.MarkBuildStepStart('Download latest chromedriver') zip_path = os.path.join(util.MakeTempDir(), 'build.zip') if gsutil_download.DownloadLatestFile(GS_PREBUILTS_URL, 'r', zip_path): util.MarkBuildStepError() util.Unzip(zip_path, chrome_paths.GetBuildDir(['host_forwarder']))
def DownloadChrome(revision, dest_dir, site=Site.CHROMIUM_SNAPSHOT): """Downloads the packaged Chrome from the archive to the given directory. Args: revision: the revision of Chrome to download. dest_dir: the directory to download Chrome to. site: the archive site to download from, default to the snapshot one. Returns: The path to the unzipped Chrome binary. """ def GetZipName(revision): if util.IsWindows(): return revision + '/chrome-win32.zip' elif util.IsMac(): return revision + '/chrome-mac.zip' elif util.IsLinux(): if util.Is64Bit(): return revision + '/chrome-linux.zip' else: return 'full-build-linux_' + revision + '.zip' def GetDirName(): if util.IsWindows(): return 'chrome-win32' elif util.IsMac(): return 'chrome-mac' elif util.IsLinux(): if util.Is64Bit(): return 'chrome-linux' else: return 'full-build-linux' def GetChromePathFromPackage(): if util.IsWindows(): return 'chrome.exe' elif util.IsMac(): return 'Chromium.app/Contents/MacOS/Chromium' elif util.IsLinux(): return 'chrome-wrapper' zip_path = os.path.join(dest_dir, 'chrome-%s.zip' % revision) if not os.path.exists(zip_path): url = site + '/%s/%s' % (_GetDownloadPlatform(), GetZipName(revision)) print 'Downloading', url, '...' urllib.urlretrieve(url, zip_path) util.Unzip(zip_path, dest_dir) return os.path.join(dest_dir, GetDirName(), GetChromePathFromPackage())
def _Release(build, version, platform): """Releases the given candidate build.""" release_name = 'chromedriver_%s.zip' % platform util.MarkBuildStepStart('releasing %s' % release_name) temp_dir = util.MakeTempDir() slave_utils.GSUtilCopy(build, temp_dir) zip_path = os.path.join(temp_dir, os.path.basename(build)) if util.IsLinux(): util.Unzip(zip_path, temp_dir) server_path = os.path.join(temp_dir, 'chromedriver') util.RunCommand(['strip', server_path]) zip_path = util.Zip(server_path) slave_utils.GSUtilCopy( zip_path, '%s/%s/%s' % (GS_CHROMEDRIVER_BUCKET, version, release_name)) _MaybeUpdateLatestRelease(version)
def _Run(java_tests_src_dir, test_filter, chromedriver_path, chrome_path, log_path, android_package_key, verbose, debug): """Run the WebDriver Java tests and return the test results. Args: java_tests_src_dir: the java test source code directory. test_filter: the filter to use when choosing tests to run. Format is same as Google C++ Test format. chromedriver_path: path to ChromeDriver exe. chrome_path: path to Chrome exe. log_path: path to server log. android_package_key: name of Chrome's Android package. verbose: whether the output should be verbose. debug: whether the tests should wait until attached by a debugger. Returns: A list of |TestResult|s. """ test_dir = util.MakeTempDir() keystore_path = ('java', 'client', 'test', 'keystore') required_dirs = [ keystore_path[:-1], ('javascript', ), ('third_party', 'closure', 'goog'), ('third_party', 'js') ] for required_dir in required_dirs: os.makedirs(os.path.join(test_dir, *required_dir)) test_jar = 'test-standalone.jar' class_path = test_jar shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'), os.path.join(test_dir, *keystore_path)) util.Unzip(os.path.join(java_tests_src_dir, 'common.zip'), test_dir) shutil.copyfile(os.path.join(java_tests_src_dir, test_jar), os.path.join(test_dir, test_jar)) sys_props = [ 'selenium.browser=chrome', 'webdriver.chrome.driver=' + os.path.abspath(chromedriver_path) ] if chrome_path: if util.IsLinux() and android_package_key is None: # Workaround for crbug.com/611886 and # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1695 chrome_wrapper_path = os.path.join(test_dir, 'chrome-wrapper-no-sandbox') with open(chrome_wrapper_path, 'w') as f: f.write('#!/bin/sh\n') f.write('exec %s --no-sandbox --disable-gpu "$@"\n' % os.path.abspath(chrome_path)) st = os.stat(chrome_wrapper_path) os.chmod(chrome_wrapper_path, st.st_mode | stat.S_IEXEC) else: chrome_wrapper_path = os.path.abspath(chrome_path) sys_props += ['webdriver.chrome.binary=' + chrome_wrapper_path] if log_path: sys_props += ['webdriver.chrome.logfile=' + log_path] if android_package_key: android_package = constants.PACKAGE_INFO[android_package_key].package sys_props += ['webdriver.chrome.android_package=' + android_package] if android_package_key == 'chromedriver_webview_shell': android_activity = constants.PACKAGE_INFO[ android_package_key].activity android_process = '%s:main' % android_package sys_props += [ 'webdriver.chrome.android_activity=' + android_activity ] sys_props += [ 'webdriver.chrome.android_process=' + android_process ] if test_filter: # Test jar actually takes a regex. Convert from glob. test_filter = test_filter.replace('*', '.*') sys_props += ['filter=' + test_filter] jvm_args = [] if debug: transport = 'dt_socket' if util.IsWindows(): transport = 'dt_shmem' jvm_args += [ '-agentlib:jdwp=transport=%s,server=y,suspend=y,' 'address=33081' % transport ] # Unpack the sources into the test directory and add to the class path # for ease of debugging, particularly with jdb. util.Unzip(os.path.join(java_tests_src_dir, 'test-nodeps-srcs.jar'), test_dir) class_path += ':' + test_dir return _RunAntTest(test_dir, 'org.openqa.selenium.chrome.ChromeDriverTests', class_path, sys_props, jvm_args, verbose)