Beispiel #1
0
def set_assignee(project, issue_type, name):
    """Assign new default assignee for certain ticket type"""

    config = helper_config.get_config()

    if project == "oms3":
        if issue_type == "bug":
            config.set(config.sections()[2], 'assignee_oms3_bug_value', name)
        elif issue_type == "improvement":
            config.set(config.sections()[2], 'assignee_improvement_value',
                       name)
        elif issue_type == "feature":
            config.set(config.sections()[2], 'assignee_feature_value', name)
    elif project == "oms4":
        if issue_type == "bug":
            config.set(config.sections()[2], 'assignee_oms4_bug_value', name)
        elif issue_type == "improvement":
            config.set(config.sections()[2], 'assignee_improvement_value',
                       name)
        elif issue_type == "feature":
            config.set(config.sections()[2], 'assignee_feature_value', name)
    elif project == "oms6":
        if issue_type == "bug":
            config.set(config.sections()[2], 'assignee_oms6_bug_value', name)
        elif issue_type == "improvement":
            config.set(config.sections()[2], 'assignee_improvement_value',
                       name)
        elif issue_type == "feature":
            config.set(config.sections()[2], 'assignee_feature_value', name)

    helper_config.write_to_config(
        config,
        2,
    )
Beispiel #2
0
def create_firefox_driver(service_log_path: str):
    """
    Creates a firefox instance with a preset profile
    :return:
    """
    firefox_options = FirefoxOptions()
    firefox_options.log.level = "info"

    from elticket import helper_config

    config = helper_config.get_config()
    firefox_profile_dir = config.get(config.sections()[1],
                                     'firefox_profile_dir')

    if firefox_profile_dir:
        profile = webdriver.FirefoxProfile(
            profile_directory=firefox_profile_dir)
        profile.accept_untrusted_certs = True
        driver = webdriver.Firefox(firefox_profile=profile,
                                   options=firefox_options,
                                   service_log_path=service_log_path)
    else:
        driver = webdriver.Firefox(options=firefox_options,
                                   service_log_path=service_log_path)
    driver.implicitly_wait(10)  # function requires Firefox 53.0 or higher

    return driver
def fill_in_element(driver: webdriver.WebDriver,
                    by: By,
                    locator,
                    content,
                    confirm=False):
    config = helper_config.get_config()
    wait_until_confirm_selection = config.getfloat(
        config.sections()[1], 'wait_until_confirm_selection')

    # from selenium.webdriver.support.wait import WebDriverWait
    try:
        if retry_element_is_visible(driver, by, locator):
            WebDriverWait(driver,
                          10).until(ec.element_to_be_clickable((by, locator)))
            element = driver.find_element_by_id(locator)
            if retry_element_can_be_filled(driver, By.ID, locator, content):
                if confirm:
                    time.sleep(wait_until_confirm_selection)
                    element.send_keys(Keys.RETURN)
                logging.info("Entered information in %s" % str(locator))

    except NoSuchElementException:
        logging.error("Cannot find the element %s" % str(locator))
    except StaleElementReferenceException:
        logging.error("Element %s is not available" % str(locator))
Beispiel #4
0
def login(browser: webdriver.WebDriver):
    """
    The login(driver) function is used to login into JIRA

    :param browser: instance of a selenium.webdriver() object
    :return: No return value
    """
    from elticket import helper_config
    config = helper_config.get_config()
    have_dns = config.getboolean(config.sections()[0], 'have_dns')
    homepage_url_no_dns = config.get(config.sections()[0],
                                     'homepage_url_no_dns')
    homepage_url = config.get(config.sections()[0], 'homepage_url')
    login_user = config.get(config.sections()[2], 'user_value')
    login_pw = config.get(config.sections()[2], 'pw_value')

    if have_dns:
        browser.get(homepage_url)
    else:
        browser.get(homepage_url_no_dns)

    fld_user = browser.find_element_by_id(elements_jira.fld_login_user_id)
    fld_user.click()
    retry_element_is_focused(browser, fld_user)
    fld_user.send_keys(login_user)

    fld_pw = browser.find_element_by_id(elements_jira.fld_login_pw_id)
    fld_pw.click()
    retry_element_is_focused(browser, fld_pw)
    fld_pw.send_keys(login_pw)

    btn_login = browser.find_element_by_id(elements_jira.btn_login_id)
    btn_login.click()
Beispiel #5
0
def config_value_is_empty(section, key):
    config = helper_config.get_config()
    try:
        if config.get(config.sections()[section], key):
            return False
        else:
            return True
    except KeyError:
        pass
def retry_element_is_focused(driver: webdriver.WebDriver, element):
    i = 0
    config = helper_config.get_config()
    wait_until_confirm_selection = config.getfloat(
        config.sections()[1], 'wait_until_confirm_selection')

    while not element == driver.switch_to.active_element:
        element.click()
        time.sleep(wait_until_confirm_selection + i)
        i += 0.1
Beispiel #7
0
def create(project, issue_type, browser_option):
    browser = brwsr.select_browser(browser_option)

    print(
        "Executing automatic E+L Jira ticket creator version {0} ... ".format(
            __version__))

    jira.login(browser)
    jira.check_login(browser)
    jira.open_new_ticket(browser)
    jira.fill_in_project_information(browser, project)
    jira.fill_in_type_information(browser, issue_type)

    config = helper_config.get_config()
    assignee = environment_path = description_path = ""

    if project == "oms6":
        environment_path = jira_cfg.oms6_environment_desc_filepath

        if issue_type == "bug":
            assignee = config.get(config.sections()[2],
                                  'assignee_oms6_bug_value')
            description_path = jira_cfg.oms6_bug_desc_filepath

        elif issue_type == "feature":
            assignee = config.get(config.sections()[2],
                                  'assignee_feature_value')
            description_path = jira_cfg.feature_desc_filepath

        elif issue_type == "improvement":
            assignee = config.get(config.sections()[2],
                                  'assignee_improvement_value')
            description_path = jira_cfg.improvement_desc_filepath

    elif project == "oms4":
        environment_path = jira_cfg.oms4_environment_desc_filepath

        if issue_type == "bug":
            assignee = config.get(config.sections()[2],
                                  'assignee_oms4_bug_value')
            description_path = jira_cfg.oms4_bug_desc_filepath

        elif issue_type == "feature":
            assignee = config.get(config.sections()[2],
                                  'assignee_feature_value')
            description_path = jira_cfg.feature_desc_filepath

        elif issue_type == "improvement":
            assignee = config.get(config.sections()[2],
                                  'assignee_improvement_value')
            description_path = jira_cfg.improvement_desc_filepath

    elif project == "oms3":
        environment_path = jira_cfg.oms3_environment_desc_filepath

        if issue_type == "bug":
            assignee = config.get(config.sections()[2],
                                  'assignee_oms3_bug_value')
            description_path = jira_cfg.oms3_bug_desc_filepath

        elif issue_type == "feature":
            assignee = config.get(config.sections()[2],
                                  'assignee_feature_value')
            description_path = jira_cfg.feature_desc_filepath

        elif issue_type == "improvement":
            assignee = config.get(config.sections()[2],
                                  'assignee_improvement_value')
            description_path = jira_cfg.improvement_desc_filepath

    jira.fill_in_assignee(browser, assignee)
    jira.fill_in_environment_information(browser, issue_type, environment_path)
    jira.fill_in_description(browser, description_path)
    logging.info("Creation complete")
    print("Please enter your data and submit the ticket.")
    print("Close the browser instance afterwards...")

    if isinstance(browser, Firefox):
        helper_selenium.wait_until_firefox_is_closed(browser)