Example #1
0
def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  with open(os.path.join(_THIS_DIR, 'chrome', 'version.cc'), 'r') as f:
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, f.readlines())
  version = version_line[0].split('"')[1]

  bitness = '32'
  if util.IsLinux():
    bitness = '64'
  zip_name = 'chromedriver2_%s%s_%s.zip' % (
      util.GetPlatformName(), bitness, version)

  site = 'https://code.google.com/p/chromedriver/downloads/list'
  s = urllib2.urlopen(site)
  downloads = s.read()
  s.close()

  if zip_name in downloads:
    return 0

  print '@@@BUILD_STEP releasing %s@@@' % zip_name
  if util.IsWindows():
    server_orig_name = 'chromedriver2_server.exe'
    server_name = 'chromedriver.exe'
  else:
    server_orig_name = 'chromedriver2_server'
    server_name = 'chromedriver'
  server = os.path.join(chrome_paths.GetBuildDir([server_orig_name]),
                        server_orig_name)

  print 'Zipping ChromeDriver server', server
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  f.write(server, server_name)
  if util.IsLinux() or util.IsMac():
    adb_commands = os.path.join(_THIS_DIR, 'chrome', 'adb_commands.py')
    f.write(adb_commands, 'adb_commands.py')
  f.close()

  cmd = [
    sys.executable,
    os.path.join(_THIS_DIR, 'third_party', 'googlecode',
                 'googlecode_upload.py'),
    '--summary', 'version of ChromeDriver2 r%s' % revision,
    '--project', 'chromedriver',
    '--user', '*****@*****.**',
    '--label', 'Release',
    zip_path
  ]
  with open(os.devnull, 'wb') as no_output:
    if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait():
      print '@@@STEP_FAILURE@@@'
Example #2
0
 def GetChromePathFromPackage():
     if util.IsWindows():
         return 'chrome.exe'
     elif util.IsMac():
         return 'Chromium.app/Contents/MacOS/Chromium'
     elif util.IsLinux():
         return 'chrome'
Example #3
0
 def GetZipName():
     if util.IsWindows():
         return 'chrome-win32'
     elif util.IsMac():
         return 'chrome-mac'
     elif util.IsLinux():
         return 'chrome-linux'
Example #4
0
def _GetDownloadPlatform():
    """Returns the name for this platform on the archive site."""
    if util.IsWindows():
        return 'Win'
    elif util.IsMac():
        return 'Mac'
    elif util.IsLinux():
        return 'Linux_x64'
Example #5
0
def _GetDownloadPlatform():
    """Returns the name for this platform on the archive site."""
    if util.IsWindows():
        return 'Win'
    elif util.IsMac():
        return 'Mac'
    elif util.IsLinux():
        if platform.architecture()[0] == '64bit':
            return 'Linux_x64'
        else:
            return 'Linux'
Example #6
0
def Main():
    chromedriver_map = {
        'win': 'chromedriver2.dll',
        'mac': 'chromedriver2.so',
        'linux': 'libchromedriver2.so',
    }
    chromedriver = chromedriver_map[util.GetPlatformName()]
    build_dir = chrome_paths.GetBuildDir([chromedriver])
    chrome_binary = _FindChromeBinary(build_dir)
    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    # Run python test for chromedriver.
    print '@@@BUILD_STEP chromedriver2_python_tests@@@'
    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test.py'),
        os.path.join(build_dir, chromedriver),
    ]
    # Set the built chrome binary.
    if chrome_binary is not None:
        cmd.append(chrome_binary)
    if util.IsMac():
        # In Mac, chromedriver2.so is a 32-bit build, so run with the 32-bit python.
        os.environ['VERSIONER_PYTHON_PREFER_32_BIT'] = 'yes'
    code1 = util.RunCommand(cmd)
    if code1 != 0:
        print '@@@STEP_FAILURE@@@'

    # Run java tests for chromedriver.
    print '@@@BUILD_STEP chromedriver2_java_tests@@@'
    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'run_java_tests.py'),
        '--chromedriver_path=' + os.path.join(build_dir, chromedriver),
    ]
    # Set the built chrome binary.
    if chrome_binary is not None:
        cmd.append('--chrome_path=' + chrome_binary)
    code2 = util.RunCommand(cmd)
    if code2 != 0:
        print '@@@STEP_FAILURE@@@'

    return code1 or code2
Example #7
0
def _FindChromeBinary(path):
    if util.IsLinux():
        exes = ['chrome']
    elif util.IsMac():
        exes = [
            'Google Chrome.app/Contents/MacOS/Google Chrome',
            'Chromium.app/Contents/MacOS/Chromium'
        ]
    elif util.IsWindows():
        exes = ['chrome.exe']
    else:
        exes = []
    for exe in exes:
        binary = os.path.join(path, exe)
        if os.path.exists(binary):
            return binary
    return None
Example #8
0
def main():
  chromedriver_map = {
    'win': 'chromedriver2.dll',
    'mac': 'chromedriver2.so',
    'linux': 'libchromedriver2.so',
  }
  chromedriver_name = chromedriver_map[util.GetPlatformName()]

  chrome_map = {
    'win': 'chrome.exe',
    'mac': 'Chromium.app/Contents/MacOS/Chromium',
    'linux': 'chrome',
  }
  chrome_name = chrome_map[util.GetPlatformName()]

  if util.IsWindows():
    cpp_tests_name = 'chromedriver2_tests.exe'
  else:
    cpp_tests_name = 'chromedriver2_tests'

  required_build_outputs = [chromedriver_name, chrome_name, cpp_tests_name]
  build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, chromedriver_name)
  chrome = os.path.join(build_dir, chrome_name)
  cpp_tests = os.path.join(build_dir, cpp_tests_name)

  if util.IsLinux():
    # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
    # when chromedriver2.so is not a static build.
    _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib'))
  elif util.IsWindows():
    # For Windows bots: add ant, java(jre) and the like to system path.
    _AddToolsToSystemPathForWindows()

  code1 = RunPythonTests(chromedriver, chrome)
  code2 = RunJavaTests(chromedriver, chrome)
  code3 = RunCppTests(cpp_tests)
  return code1 or code2 or code3
Example #9
0
"""TestEnvironment classes.

These classes abstract away the various setups needed to run the WebDriver java
tests in various environments.
"""

import os
import sys

_THIS_DIR = os.path.abspath(os.path.dirname(__file__))

sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib'))

from common import util

if util.IsLinux():
    sys.path.insert(
        0,
        os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, 'build',
                     'android'))
    from pylib import android_commands
    from pylib import forwarder
    from pylib import valgrind_tools

ANDROID_TEST_HTTP_PORT = 2311
ANDROID_TEST_HTTPS_PORT = 2411

_EXPECTATIONS = {}
execfile(os.path.join(_THIS_DIR, 'test_expectations'), _EXPECTATIONS)

Example #10
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    chromedriver_map = {
        'win': 'chromedriver2.dll',
        'mac': 'chromedriver2.so',
        'linux': 'libchromedriver2.so',
    }
    chromedriver_name = chromedriver_map[util.GetPlatformName()]

    chrome_map = {
        'win': 'chrome.exe',
        'mac': 'Chromium.app/Contents/MacOS/Chromium',
        'linux': 'chrome',
    }
    chrome_name = chrome_map[util.GetPlatformName()]

    if util.IsWindows():
        cpp_tests_name = 'chromedriver2_tests.exe'
        server_name = 'chromedriver2_server.exe'
    else:
        cpp_tests_name = 'chromedriver2_tests'
        server_name = 'chromedriver2_server'

    required_build_outputs = [chromedriver_name]
    if not options.android_package:
        required_build_outputs += [cpp_tests_name, server_name]
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, chromedriver_name)
    chromedriver_server = os.path.join(build_dir, server_name)

    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    if options.android_package:
        os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
        code1 = RunPythonTests(chromedriver,
                               android_package=options.android_package)
        code2 = RunJavaTests(chromedriver_server,
                             android_package=options.android_package)
        return code1 or code2
    else:
        chrome_tip_of_tree = os.path.join(build_dir, chrome_name)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)

        chrome_26 = continuous_archive.DownloadChrome(
            continuous_archive.CHROME_26_REVISION, util.MakeTempDir())
        chrome_27 = continuous_archive.DownloadChrome(
            continuous_archive.CHROME_27_REVISION, util.MakeTempDir())
        chrome_path_versions = [
            {
                'path': chrome_tip_of_tree,
                'version': 'HEAD'
            },
            {
                'path': chrome_27,
                'version': '27'
            },
            {
                'path': chrome_26,
                'version': '26'
            },
        ]
        code = 0
        for chrome in chrome_path_versions:
            if options.chrome_version and chrome[
                    'version'] != options.chrome_version:
                continue

            code1 = RunPythonTests(chromedriver,
                                   chrome=chrome['path'],
                                   chrome_version=chrome['version'])
            code2 = RunJavaTests(chromedriver_server,
                                 chrome=chrome['path'],
                                 chrome_version=chrome['version'])
            code = code or code1 or code2
        return RunCppTests(cpp_tests) or code
Example #11
0
import unittest

_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib'))

_TEST_DATA_DIR = os.path.join(_THIS_DIR, os.pardir, 'data', 'chromedriver')

from common import chrome_paths
from common import unittest_util
from common import util

import chromedriver
from webelement import WebElement
import webserver

if util.IsLinux():
  sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir,
                                  'build', 'android'))
  from pylib import android_commands
  from pylib import forwarder
  from pylib import valgrind_tools


_DESKTOP_OS_SPECIFIC_FILTER = []
if util.IsWindows():
  _DESKTOP_OS_SPECIFIC_FILTER = [
      # https://code.google.com/p/chromedriver/issues/detail?id=214
      'ChromeDriverTest.testCloseWindow',
      # https://code.google.com/p/chromedriver/issues/detail?id=299
      'ChromeLogPathCapabilityTest.testChromeLogPath',
  ]