Ejemplo n.º 1
0
def generate(driver, target, lea):
    local_driver = driver
    local_lea = lea
    local_target = target

    login(local_driver, local_lea)
    open_warrant(local_driver)
    local_driver.switch_to.frame(0)
    Select(local_driver.find_element_by_xpath("//select[@name='targetType']")).select_by_visible_text(local_target['input']['target_type'])

    xpath = "//select[@name='tspType']"
    if check_exists_by_xpath(local_driver, xpath):
        Select(local_driver.find_element_by_xpath(xpath)).select_by_visible_text(local_target['tsp_type'])

    local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['id_type']).send_keys(local_target['id'])

    xpath = "//tr[@class= 'tspRow']"
    #xpath = "//li[@value='%s']" %local_target['circle']
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("//li[@value='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['tsp']).click()

    local_driver.find_element_by_xpath("//input[@class='supFile']").send_keys("/media/vishy/download/warrant.pdf")
    local_driver.find_element_by_xpath("//a[@title='Submit Request']").click()
    msg = local_driver.switch_to.alert
    print msg.text
    warrant_id = re.search('([0-9].*[0-9])', msg.text).group(1)
    msg.accept()
    local_target['warrant'] = warrant_id
    print "Request generated successfully with warrant-id ", local_target['warrant']

    logout(local_driver)
Ejemplo n.º 2
0
def approve(driver, target, rmc, req_type):
    local_driver = driver
    local_rmc = rmc
    local_target = target
    local_req_type = req_type

    go_to_approval(local_driver, local_rmc, local_target, local_req_type)
    local_driver.find_element_by_xpath("//input[@id='tidCheck']").click()
    #local_driver.find_element_by_xpath("//input[@id='ttCheck']").click()
    #local_driver.find_element_by_xpath("//input[@id='leaCheck']").click()
    #local_driver.find_element_by_xpath("//input[@id='stateCheck']").click()
    xpath = "//input[@id='tspTypeCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" % xpath).click()
    xpath = "//input[@id='tspCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" % xpath).click()
    xpath = "//input[@id='eprovCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" % xpath).click()
    local_driver.find_element_by_xpath("//input[@id='provTypeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='startTimeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='stopTimeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='contentCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='issAuthCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='warrantCheck']").click()
    xpath = "//input[@id='warrantFileCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" % xpath).click()
    local_driver.find_element_by_xpath("//input[@id='warrantDateCheck']").click()
    xpath = "//input[@id='cmsWarCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" % xpath).click()
    local_driver.find_element_by_xpath("//a[@id='approve']").click()
    try:
        approval_alert = local_driver.switch_to_alert()
        vprint ("Approval Alert: " + approval_alert.text)
        approval_alert.accept()
    except NoAlertPresentException:
        vprint("No Alert Present")
    try:
        modify_alert = local_driver.switch_to_alert()
        vprint("Additional Approval Alert: " + modify_alert.text)
        modify_alert.accept()
    except NoAlertPresentException:
        vprint("No Additional Alert Present")
    local_driver.get_screenshot_as_file('/tmp/approval_%s.png' % time.strftime('%Y-%m-%d_%H-%M-%S'))

    assert "successfully approved" or "To be modified" in local_driver.page_source, local_target['id'] + " Target approval failed"
    assert local_target['id'] in local_driver.page_source, local_target['id'] + " Target approval failed"
    vprint("Target " + local_target['id'] + " successfully approved")

    logout(local_driver)
Ejemplo n.º 3
0
def go_to_approval(driver, rmc, target, req_type):
    local_driver = driver
    local_rmc = rmc
    local_target = target
    local_req_type = req_type

    for i in range(10):
        login(local_driver, local_rmc)
        open_prov(local_driver)
        local_driver.switch_to.frame(0)
        local_driver.find_element_by_xpath("//a[@name='display']").click()
        if local_req_type == "activation":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending for Approval")
        elif local_req_type == "modification":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending Approval for Modification")
        elif local_req_type == "deactivation":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending Approval for Deactivation")
        local_driver.find_element_by_xpath("//input[@id='Exact']").click()
        local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
        local_driver.find_element_by_xpath("//a[contains(text(),'Submit')]").click()
        try:
            target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr/td[11]").text
        except NoSuchElementException:
            target['status'] = local_driver.find_element_by_xpath("//p[@class='info']").text
        vprint(target['status'])
        if local_target['status'] == "Pending for Approval" or local_target[
            'status'] == "Modification pending for Approval" or local_target[
            'status'] == "Deactivation pending for Approval":
            local_driver.find_element_by_xpath("//img[@alt='Edit']").click()
            xpath = "//a[contains(text(),'PENDING WARRANT 1')]"
            if check_exists_by_xpath(local_driver, xpath) or local_req_type == "deactivation":
                break
        logout(local_driver)
        time.sleep(30)
    assert local_target['status'] == "Pending for Approval" or local_target['status'] == "Modification pending for Approval" or local_target['status'] == "Deactivation pending for Approval", "No Approval request received by RMC"
Ejemplo n.º 4
0
def deactivate(driver, target, lea):
    local_driver = driver
    local_lea = lea
    local_target = target

    login(local_driver, local_lea)

    open_prov(local_driver)

    local_driver.switch_to.frame(0)
    local_driver.find_element_by_xpath("//a[@name='display']").click()
    local_driver.find_element_by_xpath("//input[@id='Exact']").click()
    local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
    local_driver.find_element_by_xpath("//a[contains(.,'Submit')]").click()
    xpath = "//img[@alt='Edit']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath(xpath).click()
    else:
        print local_target['id'] + " not activated " + local_driver.find_element_by_xpath("//p[@class='info']").text
        logout(local_driver)
        return
    local_driver.find_element_by_xpath("//img[@onclick='showCalendarControl(document.inputform.stopTime,1)']").click()
    local_driver.find_element_by_xpath("//a[@title='Deactivate the target']").click()
    target_in_deactivation_page = local_driver.find_element_by_xpath("//span[@id='highlight']").text
    text = time.strftime("%Y-%m-%d %H:%M:%S") + " Target " + local_target['id'] + " successfully entered for deactivation"
    assert target_in_deactivation_page == local_target['number']
    print text

    logout(local_driver)
Ejemplo n.º 5
0
def deactivate(driver, target, user, lea):
    local_driver = driver
    local_user = user
    local_lea = lea
    local_target = target

    login(local_driver, local_user)

    open_prov(local_driver)

    local_driver.switch_to.frame(0)
    local_driver.find_element_by_xpath("//a[@name='display']").click()
    local_driver.find_element_by_xpath("//input[@id='Exact']").click()
    local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
    local_driver.find_element_by_xpath("//a[contains(.,'Submit')]").click()

    try:
        col_number = 13 + len(re.findall(r'rmc', local_user['uname']))
        counter = 1
        row_lea = counter
        row_count = len(driver.find_elements_by_xpath("//table[@id='DisplayInfo']/tbody/tr"))
        xpath = "//th[@title='LEA Name']"
        if check_exists_by_xpath(local_driver, xpath):
            while counter <= row_count:
                lea_text = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[3]" %counter).text
                if lea_text == local_lea['lea_name'] + " (" + local_lea['lea_loc'] + ")":
                    row_lea = counter
                    break
                counter = counter + 1
        target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[11]" % row_lea).text
        if target['status'] == "Activated":
            local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[%s]/a/img" %(row_lea, col_number)).click()
    except NoSuchElementException:
        vprint(local_target['id'] + " not activated " + local_driver.find_element_by_xpath("//p[@class='info']").text)
        logout(local_driver)
        exit()

    #local_driver.find_element_by_xpath("//img[@onclick='showCalendarControl(document.inputform.stopTime,1)']").click()
    local_driver.find_element_by_xpath("//a[@title='Deactivate the target']").click()
    try:
        deactivate_alert = local_driver.switch_to_alert()
        vprint("Deactivation Alert: " + deactivate_alert.text)
        deactivate_alert.accept()
    except NoAlertPresentException:
        vprint("No Alert Present")
    local_driver.get_screenshot_as_file('/tmp/deactivate_%s.png' % time.strftime('%Y-%m-%d_%H-%M-%S'))
    target_in_deactivation_page = local_driver.find_element_by_xpath("//span[@id='highlight']").text

    assert target_in_deactivation_page == local_target['number']
    vprint("Target " + local_target['id'] + " successfully entered for deactivation")

    logout(local_driver)
Ejemplo n.º 6
0
def approve(driver, target, mha):
    local_driver = driver
    local_mha = mha
    local_target = target

    login(local_driver, local_mha)
    open_warrant(local_driver)
    local_driver.switch_to.frame(0)
    local_driver.find_element_by_xpath("//a[contains(text(),'Display')]").click()
    xpath = "//td[contains(@onclick,'%s')]"%local_target['warrant']
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" %xpath).click()
    else:
        print "Warrant not exists"
        logout(local_driver)
    local_driver.find_element_by_xpath("//input[@id='fileLoc']").send_keys("/media/vishy/download/warrant.pdf")
    local_driver.find_element_by_xpath("//a[contains(@onclick,'checkForm')]").click()
    local_driver.switch_to_alert().accept()
    print "Warrant approved successfully with warrant-id ", local_target['warrant']

    logout(local_driver)
Ejemplo n.º 7
0
def get(driver, target, user, lea):
    local_driver = driver
    local_user = user
    local_lea = lea
    local_target = target

    login(local_driver, local_user)

    open_prov(local_driver)
    local_driver.switch_to.frame(0)
    time.sleep(5)
    local_driver.find_element_by_xpath("//a[@name='display']").click()
    time.sleep(5)

    local_driver.find_element_by_xpath("//input[@id='Exact']").click()
    local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
    local_driver.find_element_by_xpath("//a[contains(.,'Submit')]").click()

    # Getting status of target
    try:
        row_count = len(driver.find_elements_by_xpath("//table[@id='DisplayInfo']/tbody/tr"))
        xpath = "//th[@title='LEA Name']"
        if check_exists_by_xpath(local_driver, xpath):
            counter = 1
            while counter <= row_count:
                lea_text = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[3]"%counter).text
                if lea_text == local_lea['lea_name'] + " (" + local_lea['lea_loc'] + ")":
                    target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[11]"%counter).text
                    break
                counter = counter + 1
        else:
            target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[1]/td[11]").text
    except NoSuchElementException:
        target['status'] = local_driver.find_element_by_xpath("//p[@class='info']").text

    logout(local_driver)
Ejemplo n.º 8
0
def activate(driver, target, lea):
    local_driver = driver
    local_lea = lea
    local_target = target

    login(local_driver, local_lea)
    open_prov(local_driver)
    local_driver.switch_to.frame(0)

    for key, value in local_target['input'].items():
        local_driver.find_element_by_xpath("//input[@id='%s']" %value).click()

    xpath = "//select[@name='homeTspType']"
    if check_exists_by_xpath(local_driver, xpath):
        Select(local_driver.find_element_by_xpath(xpath)).select_by_visible_text(local_target['tsp_type'])
    local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['id_type']).send_keys(local_target['id'])
    local_driver.find_element_by_xpath("//a[@title='Submit']").click()

    xpath = "//td[contains(.,'Deactivated')]"
    if check_exists_by_xpath(local_driver, xpath):
        print "Target " + local_target['id'] + " is deactivated"
        xpath1 = "%s/../td[4]//a[@title='Activate target']" %xpath
        if check_exists_by_xpath(local_driver, xpath1):
            local_driver.find_element_by_xpath(xpath1).click()
        xpath2 = "%s/../td[5]//a[@title='Activate target']" %xpath
        if check_exists_by_xpath(local_driver, xpath2):
            local_driver.find_element_by_xpath(xpath2).click()

    local_driver.find_element_by_xpath("//input[@name='alias']").send_keys(local_target['alias'])
    xpath = "//td[contains(., 'Circle')]"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("//li[@value='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['tsp']).click()
    Select(local_driver.find_element_by_xpath("//select[@name='monitoringGroup']")).select_by_visible_text(local_target['mongrp'])
    Select(local_driver.find_element_by_xpath("//select[@name='targetCase']")).select_by_visible_text(local_target['case'])
    local_driver.find_element_by_xpath("//img[@onclick='showCalendarControl(document.inputform.stopTime,1)']").click()
    current_day = int(time.strftime("%d"))
    stop_day = (current_day + 7) % 30
    if stop_day < current_day:
        local_driver.find_element_by_xpath("//a[contains(@href, 'javascript:changeCalendarControlMonth(1);')]").click()
    local_driver.find_element_by_xpath('//a[contains(text(), "%s")]' %stop_day).click()

    #local_driver.find_element_by_xpath("//input[@id='hourtext']").click()
    #local_driver.find_element_by_xpath("//input[@id='hourtext']").clear()
    #local_driver.find_element_by_xpath("//input[@id='hourtext']").clear()
    #print local_driver.find_element_by_xpath("//input[@id='hourtext']").get_attribute('value')
    #local_driver.find_element_by_xpath("//input[@id='hourtext']").send_keys('21')
    #local_driver.find_element_by_xpath("//input[@id='minutetext']").clear()
    #local_driver.find_element_by_xpath("//input[@id='minutetext']").clear()
    #local_driver.find_element_by_xpath("//input[@id='minutetext']").send_keys('34')
    # local_driver.find_element_by_xpath("//a[contains(@href, 'javascript:setCalendarControlDate(2015,9,15,10,34)')]").click()

    local_driver.find_element_by_xpath("//input[@name='warrant']").send_keys(local_target['warrant'])
    local_driver.find_element_by_xpath("//a[@title='Activate target']").click()
    text = time.strftime("%Y-%m-%d %H:%M:%S") + " Target " + local_target['id'] + " successfully entered for activation"
    target_in_activation_page = local_driver.find_element_by_xpath("//span[@id='highlight']").text
    #print "local_target:", local_target['number']
    #print "target_in_page:", target_in_activation_page
    assert target_in_activation_page == local_target['number']
    print text
    print "Hello World"


    logout(local_driver)
Ejemplo n.º 9
0
def approve(driver, target, rmc, req_type):
    local_driver = driver
    local_rmc = rmc
    local_target = target

    for i in range(10):
        login(local_driver, local_rmc)
        open_prov(local_driver)
        local_driver.switch_to.frame(0)
        local_driver.find_element_by_xpath("//a[@name='display']").click()
        if req_type == "activation":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending for Approval")
        elif req_type == "modification":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending Approval for Modification")
        elif req_type == "deactivation":
            local_driver.find_element_by_xpath("//select[@id='status']").send_keys("Pending Approval for Deactivation")
        local_driver.find_element_by_xpath("//input[@id='Exact']").click()
        local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
        local_driver.find_element_by_xpath("//a[contains(text(),'Submit')]").click()
        try:
            target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr/td[11]").text
        except NoSuchElementException:
            target['status'] = local_driver.find_element_by_xpath("//p[@class='info']").text
        print time.strftime("%Y-%m-%d %H:%M:%S"), target['status']
        if local_target['status'] == "Pending for Approval" or local_target['status'] == "Modification pending for Approval" or local_target['status'] == "Deactivation pending for Approval":
            break
        logout(local_driver)
        time.sleep(30)
    assert local_target['status'] == "Pending for Approval" or local_target['status'] == "Modification pending for Approval" or local_target['status'] == "Deactivation pending for Approval", "No Approval request received by RMC"

    local_driver.find_element_by_xpath("//img[@alt='Edit']").click()
    local_driver.find_element_by_xpath("//input[@id='tidCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='ttCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='leaCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='stateCheck']").click()
    xpath = "//input[@id='tspTypeCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" %xpath).click()
    xpath = "//input[@id='tspCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" %xpath).click()
    local_driver.find_element_by_xpath("//input[@id='provTypeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='startTimeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='stopTimeCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='contentCheck']").click()
    local_driver.find_element_by_xpath("//input[@id='warrantCheck']").click()
    xpath = "//input[@id='warrantFileCheck']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("%s" %xpath).click()
    local_driver.find_element_by_xpath("//input[@id='warrantDateCheck']").click()
    local_driver.find_element_by_xpath("//a[@id='approve']").click()
    local_driver.switch_to_alert().accept()
    try:
        local_driver.switch_to_alert().accept()
    except NoAlertPresentException:
        pass
    text = time.strftime("%Y-%m-%d %H:%M:%S") + " Target " + local_target['id'] + " successfully approved"
    assert "successfully approved" or "To be modified" in local_driver.page_source, local_target['id'] + " Target approval failed"
    assert local_target['id'] in local_driver.page_source, local_target['id'] + " Target approval failed"
    print text

    logout(local_driver)
Ejemplo n.º 10
0
def modify(driver, target, user, lea):
    local_driver = driver
    local_user = user
    local_lea = lea
    local_target = target

    login(local_driver, local_user)

    open_prov(local_driver)

    local_driver.switch_to.frame(0)
    local_driver.find_element_by_xpath("//a[@name='display']").click()
    local_driver.find_element_by_xpath("//input[@id='Exact']").click()
    local_driver.find_element_by_xpath("//input[@name='targetId']").send_keys(local_target['number'])
    local_driver.find_element_by_xpath("//a[contains(.,'Submit')]").click()
    #local_driver.find_element_by_xpath("//img[@alt='Edit']").click()


    try:
        col_number = 13 + len(re.findall(r'rmc', local_user['uname']))
        counter = 1
        row_lea = counter
        row_count = len(driver.find_elements_by_xpath("//table[@id='DisplayInfo']/tbody/tr"))
        xpath = "//th[@title='LEA Name']"
        if check_exists_by_xpath(local_driver, xpath):
            while counter <= row_count:
                lea_text = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[3]"%counter).text
                if lea_text == local_lea['lea_name'] + " (" + local_lea['lea_loc'] + ")":
                    row_lea = counter
                    break
                counter = counter + 1
        target['status'] = local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[11]" %row_lea).text
        if target['status'] == "Activated":
            local_driver.find_element_by_xpath("//table[@id='DisplayInfo']/tbody/tr[%s]/td[%s]/a/img" %(row_lea, col_number)).click()
    except NoSuchElementException:
        vprint(local_target['id'] + " not activated " + local_driver.find_element_by_xpath("//p[@class='info']").text)
        logout(local_driver)
        exit()


    # Change the input
    local_driver.find_element_by_xpath("//img[@onclick='showCalendarControl(document.inputform.stopTime,1)']").click()

    # Generating new Stop Time
    stop_time = local_driver.find_element_by_xpath("//input[@id = 'provStopTime']").get_attribute("value")
    stop_day = int(stop_time[:2])
    mod_day = (stop_day + 7) % 30
    if mod_day < stop_day:
        local_driver.find_element_by_xpath("//a[contains(@href, 'javascript:changeCalendarControlMonth(1);')]").click()
    local_driver.find_element_by_xpath('//a[contains(text(), "%s")]' % mod_day).click()

    # Generating new warrant
    old_warrant = local_driver.find_element_by_xpath("//input[@name='warrant']").get_attribute("value")
    new_warrant = old_warrant + "/new"
    if len(new_warrant) > 25:
        new_warrant = new_warrant[:11]
    local_driver.find_element_by_xpath("//input[@name='warrant']").clear()
    local_driver.find_element_by_xpath("//input[@name='warrant']").send_keys(new_warrant)
    local_driver.find_element_by_xpath("//input[@class='warFile']").send_keys("/media/vishy/download/warrant.pdf")

    local_driver.find_element_by_xpath("//a[@title='Modify the target']").click()
    try:
        modify_alert1 = local_driver.switch_to_alert()
        vprint("Modification Alert: " + modify_alert1.text)
        modify_alert1.accept()
    except NoAlertPresentException:
        vprint("No Alert Present")
    try:
        modify_alert2 = local_driver.switch_to_alert()
        vprint("Additional Modification Alert: " + modify_alert2.text)
        modify_alert2.accept()
    except NoAlertPresentException:
        vprint("No Additional Alert Present")

    local_driver.get_screenshot_as_file('/tmp/modify_%s.png' % time.strftime('%Y-%m-%d_%H-%M-%S'))
    target_in_modification_page =  local_driver.find_element_by_xpath("//table[@id='form-table']/tbody/tr/td[2]").text
    assert target_in_modification_page == local_target['number']
    vprint("Target " + local_target['id'] + " successfully entered for modification")

    # Logout from GUI
    logout(local_driver)
Ejemplo n.º 11
0
def activate(driver, target, lea):
    local_driver = driver
    local_lea = lea
    local_target = target
    login(local_driver, local_lea)
    open_prov(local_driver)
    local_driver.switch_to.frame(0)

    for key, value in local_target['input'].items():
        local_driver.find_element_by_xpath("//input[@id='%s']" %value).click()

    xpath = "//select[@name='homeTspType']"
    if check_exists_by_xpath(local_driver, xpath):
        Select(local_driver.find_element_by_xpath(xpath)).select_by_visible_text(local_target['tsp_type'])
    local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['id_type']).send_keys(local_target['id'])
    local_driver.find_element_by_xpath("//a[@title='Submit']").click()

    for current_sts in ["Deactivated", "Declined", "Error"]:
        xpath = "//td[contains(.,'%s')]"%current_sts
        if check_exists_by_xpath(local_driver, xpath):
            vprint("Target " + local_target['id'] + " is " + current_sts)
            xpath1 = "%s/../td[4]//a[@title='Activate target']" %xpath
            if check_exists_by_xpath(local_driver, xpath1):
                local_driver.find_element_by_xpath(xpath1).click()
            xpath2 = "%s/../td[5]//a[@title='Activate target']" %xpath
            if check_exists_by_xpath(local_driver, xpath2):
                local_driver.find_element_by_xpath(xpath2).click()

    local_driver.find_element_by_xpath("//input[@name='alias']").clear()
    local_driver.find_element_by_xpath("//input[@name='alias']").send_keys(local_target['alias'])
    xpath = "//td[contains(., 'Circle')]"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath("//li[@value='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['circle']).click()
        local_driver.find_element_by_xpath("//input[@id='%s']" %local_target['tsp']).click()
    #xpath = "//select[@name='monitoringGroup']"
    #if check_exists_by_xpath(local_driver, xpath):
    #   Select(local_driver.find_element_by_xpath(xpath)).select_by_visible_text(local_target['mon_grp'])
    xpath = "//button[@class='multiselect dropdown-toggle btn btn-default']"
    if check_exists_by_xpath(local_driver, xpath):
        local_driver.find_element_by_xpath(xpath).click()
        for mon_grp_id in local_target['mon_grp']:
            xpath = local_driver.find_element_by_xpath("//input[@value=%s and @type='checkbox']" %mon_grp_id)
            if not xpath.is_selected():
                xpath.click()
    Select(local_driver.find_element_by_xpath("//select[@name='targetCase']")).select_by_visible_text(local_target['case'])
    local_driver.find_element_by_xpath("//img[@onclick='showCalendarControl(document.inputform.stopTime,1)']").click()
    current_day = int(time.strftime("%d"))
    stop_day = (current_day + 7) % 30
    if stop_day < current_day:
        local_driver.find_element_by_xpath("//a[contains(@href, 'javascript:changeCalendarControlMonth(1);')]").click()
    local_driver.find_element_by_xpath('//a[contains(text(), "%s")]' %stop_day).click()
    print local_target['issuing_authority']
    Select(local_driver.find_element_by_xpath("//select[@name='issuingAuthority']")).select_by_visible_text(local_target['issuing_authority'])
    local_driver.find_element_by_xpath("//input[@name='warrant']").send_keys(local_target['warrant'])
    local_driver.find_element_by_xpath("//input[@class='warFile']").send_keys("/media/vishy/download/warrant.pdf")
    local_driver.find_element_by_xpath("//a[@title='Activate target']").click()
    try:
        activate_alert = local_driver.switch_to_alert()
        vprint("Activation Alert: " + activate_alert.text)
        activate_alert.accept()
    except NoAlertPresentException:
        vprint("No Alert Present")
    local_driver.get_screenshot_as_file('/tmp/activate_%s.png' % time.strftime('%Y-%m-%d_%H-%M-%S'))

    target_in_activation_page = local_driver.find_element_by_xpath("//span[@id='highlight']").text
    assert target_in_activation_page == local_target['number']
    vprint("Target " + local_target['id'] + " successfully entered for activation")

    logout(local_driver)