示例#1
0
 def GetChromePathFromPackage():
     if util.IsWin():
         return 'chrome.exe'
     elif util.IsMac():
         return 'Chromium.app/Contents/MacOS/Chromium'
     elif util.IsLinux():
         return 'chrome'
示例#2
0
 def GetZipName():
     if util.IsWin():
         return 'chrome-win32'
     elif util.IsMac():
         return 'chrome-mac'
     elif util.IsLinux():
         return 'chrome-linux'
示例#3
0
 def GetChromedriverPath():
     if util.IsWin():
         return 'chrome-win32.test/chromedriver.exe'
     elif util.IsMac():
         return 'chrome-mac.test/chromedriver'
     elif util.IsLinux():
         return 'chrome-linux.test/chromedriver'
示例#4
0
def DownloadChromeDriver(revision, dest_dir):
    """Downloads ChromeDriver from the archive to the given directory.

  Args:
    revision: the revision of ChromeDriver to download.
    dest_dir: the directory to download ChromeDriver to.

  Returns:
    The path to the downloaded ChromeDriver binary.
  """
    def GetChromedriverPath():
        if util.IsWin():
            return 'chrome-win32.test/chromedriver.exe'
        elif util.IsMac():
            return 'chrome-mac.test/chromedriver'
        elif util.IsLinux():
            return 'chrome-linux.test/chromedriver'

    url = _SITE + '/%s/%s/%s' % (_GetDownloadPlatform(), revision,
                                 GetChromedriverPath())
    print 'Downloading', url, '...'
    path = os.path.join(dest_dir, 'chromedriver')
    if util.IsWin():
        path = path + '.exe'
    urllib.urlretrieve(url, path)
    # Make executable by owner.
    os.chmod(path, stat.S_IEXEC)
    return path
示例#5
0
def _GetDownloadPlatform():
    """Returns the name for this platform on the archive site."""
    if util.IsWin():
        return 'Win'
    elif util.IsMac():
        return 'Mac'
    elif util.IsLinux():
        return 'Linux_x64'
示例#6
0
  def testSnapshotWithWindowlessFlashAndTransparentOverlay(self):
    if not util.IsWin():
      return

    driver = self.GetNewDriver()
    driver.get(self.GetTestDataUrl() + '/plugin_transparency_test.html')
    snapshot = driver.get_screenshot_as_base64()
    self.assertEquals(hashlib.md5(snapshot).hexdigest(),
                      '72e5b8525e48758bae59997472f27f14')
示例#7
0
 def _FindDriver():
   cd_exe_name = 'chromedriver'
   if util.IsWin():
     cd_exe_name += '.exe'
   for dir in _DefaultExeLocations():
     path = os.path.abspath(os.path.join(dir, cd_exe_name))
     if os.path.exists(path):
       return path
   return None
示例#8
0
 def _FindChrome():
   possible_paths = []
   if util.IsWin():
     possible_paths += ['chrome.exe']
   elif util.IsMac():
     possible_paths += ['Chromium.app/Contents/MacOS/Chromium',
                        'Google Chrome.app/Contents/MacOS/Google Chrome']
   elif util.IsLinux():
     possible_paths += ['chrome']
   for dir in _DefaultExeLocations():
     for chrome_path in possible_paths:
       path = os.path.abspath(os.path.join(dir, chrome_path))
       if os.path.exists(path):
         return path
   return None
示例#9
0
def Run(test_target, test_filter, webdriver_dir, chromedriver_path,
        chrome_path):
    """Runs the WebDriver Java test target and returns the results.

  Args:
    test_target: a |TestTarget| to run.
    test_filter: the Java test filter to use. Should take the form
                 MyClass#testMethod.
    webdriver_dir: the path to a WebDriver source checkout.
    chromedriver_path: the path to the ChromeDriver to use.
    chrome_path: the path to the Chrome binary to use. If None, ChromeDriver
                 will use the system Chrome installation.

  Returns:
    List of |TestResult|s.
  """
    results_path = os.path.join(webdriver_dir, 'build', 'test_logs',
                                test_target.GetResultFileName())
    if os.path.exists(results_path):
        os.remove(results_path)
    if util.IsWin():
        go_name = 'go.bat'
    else:
        go_name = 'go'
    go = os.path.join(webdriver_dir, go_name)
    command = [go, test_target.GetTargetPath()]
    command += ['haltonerror=false', 'haltonfailure=false', 'log=true']
    command += ['chromedriver=' + chromedriver_path]
    if chrome_path is not None:
        command += ['chrome=' + chrome_path]
    if test_filter is not None:
        parts = test_filter.split('#')
        if len(parts) > 2:
            raise RuntimeError(
                'Filter should be of form: SomeClass#testMethod')
        elif len(parts) == 2:
            command += ['method=' + parts[1]]
        if len(parts[0]) > 0:
            command += ['onlyrun=' + parts[0]]
    print "Running ", ' '.join(command)
    util.RunCommand(command, cwd=webdriver_dir)
    return _ProcessResults(results_path)