Beispiel #1
0
 def __init__(self, driver: WebDriver):
     self.driver = driver
     self.screenshots_folder = os.path.join(
         os.path.expanduser(ocsci_config.RUN["log_dir"]),
         f"screenshots_ui_{ocsci_config.RUN['run_id']}",
         get_current_test_name(),
     )
     if not os.path.isdir(self.screenshots_folder):
         Path(self.screenshots_folder).mkdir(parents=True, exist_ok=True)
     logger.info(f"screenshots pictures:{self.screenshots_folder}")
Beispiel #2
0
def screenshot_dom_location(type_loc="screenshot"):
    """
    Get the location for copy DOM/screenshot

    Args:
        type_loc (str): if type_loc is "screenshot" the location for copy screeenshot else DOM

    """
    base_ui_logs_dir = os.path.join(
        os.path.expanduser(ocsci_config.RUN["log_dir"]),
        f"ui_logs_dir_{ocsci_config.RUN['run_id']}",
    )
    if type_loc == "screenshot":
        return os.path.join(
            base_ui_logs_dir,
            "screenshots_ui",
            get_current_test_name(),
        )
    else:
        return os.path.join(
            base_ui_logs_dir,
            "dom",
            get_current_test_name(),
        )
Beispiel #3
0
 def __init__(self, driver):
     self.driver = driver
     self.screenshots_folder = os.path.join(
         os.path.expanduser(ocsci_config.RUN["log_dir"]),
         f"screenshots_ui_{ocsci_config.RUN['run_id']}",
         get_current_test_name(),
     )
     if not os.path.isdir(self.screenshots_folder):
         Path(self.screenshots_folder).mkdir(parents=True, exist_ok=True)
     logger.info(f"screenshots pictures:{self.screenshots_folder}")
     if config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM:
         self.storage_class = "thin_sc"
     elif config.ENV_DATA["platform"].lower() == constants.AWS_PLATFORM:
         self.storage_class = "gp2_sc"
     elif config.ENV_DATA["platform"].lower() == constants.AZURE_PLATFORM:
         self.storage_class = "managed-premium_sc"
Beispiel #4
0
def take_screenshot(driver):
    """
    Take screenshot using python code

    Args:
        driver (Selenium WebDriver)

    """
    screenshots_folder = os.path.join(
        os.path.expanduser(ocsci_config.RUN["log_dir"]),
        f"screenshots_ui_{ocsci_config.RUN['run_id']}",
        get_current_test_name(),
    )
    if not os.path.isdir(screenshots_folder):
        Path(screenshots_folder).mkdir(parents=True, exist_ok=True)
    time.sleep(1)
    filename = os.path.join(
        screenshots_folder,
        f"{datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%S.%f')}.png",
    )
    logger.info(f"Creating screenshot: {filename}")
    driver.save_screenshot(filename)
    time.sleep(0.5)