예제 #1
0
 def GetChromePathFromPackage():
     if util.IsWindows():
         return 'chrome.exe'
     elif util.IsMac():
         return 'Chromium.app/Contents/MacOS/Chromium'
     elif util.IsLinux():
         return 'chrome'
예제 #2
0
 def GetZipName():
     if util.IsWindows():
         return 'chrome-win32'
     elif util.IsMac():
         return 'chrome-mac'
     elif util.IsLinux():
         return 'chrome-linux'
예제 #3
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'
예제 #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():
        if platform.architecture()[0] == '64bit':
            return 'Linux_x64'
        else:
            return 'Linux'
예제 #5
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@@@'
예제 #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
예제 #7
0
def RunPythonTests(chromedriver, chrome):
  print '@@@BUILD_STEP chromedriver2_python_tests@@@'
  cmd = [
    sys.executable,
    os.path.join(_THIS_DIR, 'run_py_tests.py'),
    '--chromedriver=' + chromedriver,
    '--chrome=' + chrome,
  ]
  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'
  code = util.RunCommand(cmd)
  if code:
    print '@@@STEP_FAILURE@@@'
  return code
예제 #8
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
예제 #9
0
def RunPythonTests(chromedriver,
                   chrome=None,
                   chrome_version=None,
                   android_package=None):
    version_info = ''
    if chrome_version:
        version_info = '(v%s)' % chrome_version
    print '@@@BUILD_STEP chromedriver2_python_tests%s@@@' % version_info
    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'
    code = util.RunCommand(
        _GenerateTestCommand('run_py_tests.py', chromedriver, chrome,
                             chrome_version, android_package))
    if code:
        print '\n@@@STEP_FAILURE@@@'
    return code
예제 #10
0
    def _CreateBuildConfig(test_name, results_file, class_path, junit_props,
                           sys_props):
        def _SystemPropToXml(prop):
            key, value = prop.split('=')
            return '<sysproperty key="%s" value="%s"/>' % (key, value)

        jvmarg = ''
        if util.IsMac():
            # In Mac, the chromedriver library is a 32-bit build. So run 32-bit java.
            jvmarg = '<jvmarg value="-d32"/>'
        return '\n'.join([
            '<project>', '  <target name="test">',
            '    <junit %s>' % ' '.join(junit_props), '      ' + jvmarg,
            '      <formatter type="xml"/>', '      <classpath>',
            '        <pathelement location="%s"/>' % class_path,
            '      </classpath>',
            '      ' + '\n      '.join(map(_SystemPropToXml, sys_props)),
            '      <test name="%s" outfile="%s"/>' % (test_name, results_file),
            '    </junit>', '  </target>', '</project>'
        ])
예제 #11
0
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',
  ]
elif util.IsLinux():
  _DESKTOP_OS_SPECIFIC_FILTER = [
      # Xvfb doesn't support maximization.
      'ChromeDriverTest.testWindowMaximize',
      # https://code.google.com/p/chromedriver/issues/detail?id=302
      'ChromeDriverTest.testWindowPosition',
      'ChromeDriverTest.testWindowSize',
  ]
elif util.IsMac():
  _DESKTOP_OS_SPECIFIC_FILTER = [
      # https://code.google.com/p/chromedriver/issues/detail?id=304
      'ChromeDriverTest.testGoBackAndGoForward',
  ]


_DESKTOP_NEGATIVE_FILTER = {}
_DESKTOP_NEGATIVE_FILTER['HEAD'] = (
    _DESKTOP_OS_SPECIFIC_FILTER + [
        # https://code.google.com/p/chromedriver/issues/detail?id=213
        'ChromeDriverTest.testClickElementInSubFrame',
        # This test is flaky since it uses setTimeout.
        # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout.
        'ChromeDriverTest.testAlert',
    ]