Ejemplo n.º 1
0
def __start_webdriver_capture(capabilities, name, build):
    # Extra params to identify the build / job
    capabilities['build'] = build
    capabilities['name'] = name
    LOGGER.debug("Starting browser with capabilities: %s...", capabilities)
    driver = webdriver.setup_webdriver(remote=True, capabilities=capabilities)
    return driver
Ejemplo n.º 2
0
 def from_caps(cls, caps):
     browsername = caps['browserName']
     browserversion = caps.get('version') or ''
     configname = browsername + browserversion
     driver = webdriver.setup_webdriver(drivertype=WebDriverType.REMOTE,
                                        capabilities=caps)
     return cls(configname, driver, caps)
Ejemplo n.º 3
0
 def from_config(cls, configname, buildname=None,
                 wait_time=3, wait_for_load=True):
     if configname == 'phantomjs':
         driver = webdriver.setup_webdriver(
             drivertype=WebDriverType.PHANTOM_JS)
         caps = configname
         # Override wait_for_load since it doesn't work with phantomjs
         # Override wait_time on tag render for phantomjs to be shorter
         wait_for_load = False
         wait_time = 1
     else:
         caps = TagCapture.__get_capabilities_for_config(
             configname, buildname)
         driver = webdriver.setup_webdriver(drivertype=WebDriverType.REMOTE,
                                            capabilities=caps)
     return cls(configname, driver, caps,
                wait_time=wait_time, wait_for_load=wait_for_load)
Ejemplo n.º 4
0
def __capture_tags(capabilities,
                   tags,
                   pathbuilder,
                   tagsizes=settings.DEFAULT.tagsizes,
                   tagtypes=settings.DEFAULT.tagtypes,
                   capture_existing=False):
    num_existing_skipped = 0
    num_captured = 0
    browser_errors = []
    driver = webdriver.setup_webdriver(capabilities)

    try:
        for cid in tags:
            pathbuilder.cid = cid
            tags_per_campaign = tags[cid]
            # LOGGER.debug("tags_per_campaign: %s", str(tags_per_campaign))
            # TODO: Refactor better with __capture_tag
            # It's weird that we pass in a pathbuilder object and do two nested loops here
            for tagsize in tagsizes:
                if tagsize not in tags_per_campaign:
                    LOGGER.warn(
                        "No tagsize '%s' found for campaign: %s. Skipping",
                        tagsize, cid)
                    continue
                pathbuilder.tagsize = tagsize
                for tagtype in tagtypes:
                    pathbuilder.tagtype = tagtype
                    r = __capture_tag(pathbuilder=pathbuilder,
                                      tags_per_campaign=tags_per_campaign,
                                      driver=driver,
                                      capture_existing=capture_existing)
                    if r is None:
                        num_existing_skipped += 1
                    elif r is False:
                        continue
                    else:
                        browser_errors += r
                        num_captured += 1
            LOGGER.debug("Captured tags for campaign %s on %s", cid,
                         capabilities)
    except KeyboardInterrupt:
        driver.quit()
        driver = None
    finally:
        if driver:
            driver.quit()
    LOGGER.info(
        "Captured %s tags, skipped %s existing tags for config=%s.  Found %s errors",
        num_captured, num_existing_skipped, capabilities, len(browser_errors))
    return browser_errors
Ejemplo n.º 5
0
def __capture_tags(capabilities, tags, pathbuilder,
                   tagsizes=settings.DEFAULT.tagsizes,
                   tagtypes=settings.DEFAULT.tagtypes,
                   capture_existing=False):
    num_existing_skipped = 0
    num_captured = 0
    browser_errors = []
    driver = webdriver.setup_webdriver(capabilities)

    try:
        for cid in tags:
            pathbuilder.cid = cid
            tags_per_campaign = tags[cid]
            # LOGGER.debug("tags_per_campaign: %s", str(tags_per_campaign))
            # TODO: Refactor better with __capture_tag
            # It's weird that we pass in a pathbuilder object and do two nested loops here
            for tagsize in tagsizes:
                if tagsize not in tags_per_campaign:
                    LOGGER.warn("No tagsize '%s' found for campaign: %s. Skipping",
                                tagsize, cid)
                    continue
                pathbuilder.tagsize = tagsize
                for tagtype in tagtypes:
                    pathbuilder.tagtype = tagtype
                    r = __capture_tag(pathbuilder=pathbuilder,
                                      tags_per_campaign=tags_per_campaign,
                                      driver=driver,
                                      capture_existing=capture_existing)
                    if r is None:
                        num_existing_skipped += 1
                    elif r is False:
                        continue
                    else:
                        browser_errors += r
                        num_captured += 1
            LOGGER.debug("Captured tags for campaign %s on %s", cid, capabilities)
    except KeyboardInterrupt:
        driver.quit()
        driver = None
    finally:
        if driver:
            driver.quit()
    LOGGER.info(
        "Captured %s tags, skipped %s existing tags for config=%s.  Found %s errors",
        num_captured, num_existing_skipped, capabilities, len(browser_errors))
    return browser_errors