Beispiel #1
0
def sign(usr, passw, formUrl, Image):

    try:
        logger.info("Starting process")
        browser = helpers.GetBrowser()
        try:
            helpers.ping(browser, 'infogan')
        except:
            logger.debug('Unable to ping')

        browser.get(formUrl)
        helpers.log_browser(browser)
        #get needed elements
        employee_id = '//*[@id="user_nm"]'
        empoyee_pass = '******'

        browser.find_element_by_xpath(employee_id).send_keys(usr)
        browser.find_element_by_xpath(empoyee_pass).send_keys(passw)

        #Login
        browser.find_element_by_xpath('//*[@type="submit"]').click()
        time.sleep(4)
        browser.find_element_by_xpath('//*[@for="chkApprove"]').click()
        browser.find_element_by_xpath('//*[@id="btnSubmit"]').click()

        helpers.log_browser(browser)
        helpers.fullpage_screenshot(browser, Image)

        return 1
    except Exception as ex:
        logger.error(str(ex))
        return 0
def sign(email, user_id, password, Image):

    try:
        logger.info("Starting process")
        browser = helpers.GetBrowser()
        try:
            helpers.ping(browser, 'infogan')
        except:
            logger.debug('Unable to ping')

        browser.delete_all_cookies()
        browser.get(
            "https://amdocsprodmain.service-now.com/one_portal?id=aop_sc_cat_item&sys_id=781f12f1db5cd8903780e1aa4b961903"
        )
        helpers.log_browser(browser)

        time.sleep(4)

        # Email page
        xpath_email = browser.find_element_by_xpath('//*[@id="i0116"]')
        xpath_email_submit = browser.find_element_by_xpath(
            '//*[@id="idSIButton9"]')

        xpath_email.send_keys(email)
        xpath_email_submit.click()

        time.sleep(4)

        # User and Password page
        xpath_user = browser.find_element_by_xpath('//*[@id="userNameInput"]')
        xpath_password = browser.find_element_by_xpath(
            '//*[@id="passwordInput"]')
        xpath_sign_in = browser.find_element_by_xpath(
            '//*[@id="submitButton"]')

        xpath_user.clear()
        xpath_user.send_keys("ntnet\\" + user_id)
        xpath_password.send_keys(password)
        xpath_sign_in.click()

        time.sleep(4)

        # Declaration
        xpath_approved = browser.find_element_by_xpath(
            "//input[@name='u_approved']")
        xpath_submit = browser.find_element_by_xpath(
            "//button[@name='submit']")

        xpath_approved.click()
        xpath_submit.click()

        helpers.log_browser(browser)
        helpers.fullpage_screenshot(browser, Image)

        return 1
    except Exception as ex:
        logger.error(str(ex))
        return 0
Beispiel #3
0
def sign(parentName, parentId, kidName, kidId, formUrl, Image):

    try:
        logger.info("Starting process")
        browser = helpers.GetBrowser()
        try:
            helpers.ping(browser, 'infogan')
        except:
            logger.debug('Unable to ping')

        browser.get(formUrl)
        helpers.log_browser(browser)
        #get needed elements
        kid_id = '//*[@id="form-field-email"]'
        kid_name = '//*[@id="form-field-name"]'
        parent_id = '//*[@id="form-field-field_4"]'
        parent_name = '//*[@id="form-field-field_3"]'
        form_date = '//*[@id="form-field-field_2"]'

        #Fill Date
        browser.find_element_by_xpath(form_date).send_keys(
            str(datetime.now().date()))
        # #UnFocus Date Fiels
        # browser.find_element_by_xpath(kid_id).click()
        #Fill Kid id
        browser.find_element_by_xpath(kid_id).send_keys(str(kidId))
        #Fill Kid Name
        browser.find_element_by_xpath(kid_name).send_keys(str(kidName))
        #Fill Parent ID
        browser.find_element_by_xpath(parent_id).send_keys(str(parentId))
        #Fill Parent NAme
        browser.find_element_by_xpath(parent_name).send_keys(str(parentName))

        #Set Checkbox
        browser.find_element_by_xpath(
            '//*[@id="form-field-field_1-0"]').click()
        browser.find_element_by_xpath(
            '//*[@id="form-field-field_1-1"]').click()
        browser.find_element_by_xpath(
            '//*[@id="form-field-field_1-2"]').click()
        browser.find_element_by_xpath('//*[@id="form-field-field_5"]').click()

        #Send The Form
        browser.find_element_by_xpath('//*[@type="submit"]').submit()

        time.sleep(2)
        helpers.log_browser(browser)
        helpers.fullpage_screenshot(browser, Image)
        return 1
    except Exception as ex:
        logger.error(str(ex))
        return 0
Beispiel #4
0
def sign(userCode, sitePassword, Image):
    try:
        #### Starting Sign Proc ####
        logger.info("Starting process")
        logger.debug(
            '-----------------------0000000000-----------------------------------------------'
        )
        logger.debug(str(Image))
        #### Initialize Browser ####
        browser = helpers.GetBrowser()

        try:
            helpers.ping(browser, 'edu')
        except:
            logger.debug('Unable to ping')

        browser.get(
            "https://parents.education.gov.il/prhnet/parents/rights-obligations-regulations/health-statement-kindergarden"
        )
        start = '//*[@id="main-content"]/section[1]/div/health-declaration/div/div[1]/div[4]/div/div/div/input'
        time.sleep(2)
        helpers.fullpage_screenshot(browser, Image)
        helpers.log_browser(browser)
        browser.find_element_by_xpath(start).click()
        time.sleep(2)

        #### Logging In ####
        user = '******'
        siteAccess = '//*[@id="Ecom_Password"]'
        NextPhase = '//*[@id="loginButton2"]'
        browser.find_element_by_xpath(user).send_keys(userCode)
        browser.find_element_by_xpath(siteAccess).send_keys(sitePassword)
        browser.find_element_by_xpath(NextPhase).click()
        time.sleep(2)
        helpers.log_browser(browser)
        logger.info(f"Logged in")
        time.sleep(2)

        try:
            element = "//input[@value='מילוי הצהרת בריאות']"
            checkForButton = browser.find_elements_by_xpath(element)
            LenCheckForButton = len(checkForButton)
            logger.info(f"Starting sign... check buttons: {LenCheckForButton}")
            if LenCheckForButton == 0:
                logger.error("Not able to find the check buttons. Exit")
                helpers.fullpage_screenshot(browser, Image)

            elif LenCheckForButton > 0:
                for x in range(LenCheckForButton):
                    logger.info(x + 1)
                    browser.find_element_by_xpath(element).click()
                    time.sleep(2)
                    ToApprove = browser.find_elements_by_xpath(
                        "//input[@value='אישור']")

                    for a in ToApprove:
                        browser.execute_script("arguments[0].click()", a)
                    time.sleep(2)
        except Exception as ex:
            logger.error(str(ex))

        helpers.fullpage_screenshot(browser, Image)
        browser.close()
        return 1
    except Exception as ex:
        logger.info(
            '#################################################################################################'
        )
        logger.error(str(ex))
        browser.close()
        return 0
Beispiel #5
0
def sign(Image):
    list = ReadConfig()
    try:
        logger.info("Starting process")
        browser = helpers.GetBrowser()

        time.sleep(1)
        try:
            helpers.ping(browser, 'hbinov')
        except:
            logger.debug('Unable to ping')

        browser.get(str(list['hbinov']['URL']))
        time.sleep(1)

        # #get needed elements
        Identity = '//*[@id="Identity"]'
        Password = '******'
        Login = '******'
        Full_Name = '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div[2]/div/input'
        Mobile_Phone = '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div/div[4]/div/div[2]/div/input'
        Worker_ID = '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div/div[5]/div/div[2]/div/input'

        ######## Fill Login Details #####
        logger.info("Logging in")
        #Fill Username
        browser.find_element_by_xpath(Identity).send_keys(
            str(list['hbinov']['USER_NAME']))
        #Fill Password
        browser.find_element_by_xpath(Password).send_keys(
            str(list['hbinov']['PASSWORD']))
        # #Login
        browser.find_element_by_xpath(Login).click()
        time.sleep(2)
        logger.info("Logged in!")

        browser.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div[2]/div[1]/a').click()
        time.sleep(1)

        logger.info('Selecting Project and Review')
        project = browser.find_element_by_xpath(
            "//span[@aria-owns='ProjectId_listbox']")
        project.click()
        project.send_keys(Keys.ARROW_DOWN)
        project.send_keys(Keys.RETURN)

        ReviewInfoId = browser.find_element_by_xpath(
            "//span[@aria-owns='ReviewInfoId_listbox']")
        ReviewInfoId.click()
        ReviewInfoId.send_keys(Keys.ARROW_DOWN)
        ReviewInfoId.send_keys(Keys.RETURN)

        browser.find_element_by_xpath('//*[@id="setupSave"]').click()
        time.sleep(2)
        helpers.log_browser(browser)
        ######### Filling up the form ############

        helpers.fullpage_screenshot(browser, Image)
        browser.find_element_by_xpath(Full_Name).clear()
        browser.find_element_by_xpath(Full_Name).send_keys(
            str(list['hbinov']['NAME']))

        browser.find_element_by_xpath(Mobile_Phone).clear()
        browser.find_element_by_xpath(Mobile_Phone).send_keys(
            str(list['hbinov']['MOBILE']))

        browser.find_element_by_xpath(Worker_ID).clear()
        browser.find_element_by_xpath(Worker_ID).send_keys(
            str(list['hbinov']['ID']))

        browser.find_element_by_xpath('//*[@id="466557"]').click()
        browser.find_element_by_xpath('//*[@id="466559"]').click()
        browser.find_element_by_xpath('//*[@id="466561"]').click()

        browser.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div/div[10]/div/div[2]/div/div[1]'
        ).click()
        time.sleep(1)

        canvas = browser.find_element_by_class_name("sigCanvas")
        drawing = ActionChains(browser)\
            .click_and_hold(canvas)\
            .move_by_offset(0, 0)\
            .move_by_offset(20, 32)\
            .move_by_offset(10, 25)\
            .release()
        drawing.perform()

        browser.find_element_by_xpath(
            '/html/body/aside[2]/div/div/a[2]').click()

        signiture = browser.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div/div[10]/div/div[2]/div/div[2]/img'
        )
        with open('/opt/dockerbot/config/' + str(list['hbinov']['SIG_FILE']),
                  'r') as file:
            data = file.read().replace('\n', '')
            browser.execute_script(
                "arguments[0].setAttribute('src', '" + data + "')", signiture)

        browser.find_element_by_xpath(
            '/html/body/div[1]/div[2]/div/div/div[1]/div[3]/div/a').click()

        helpers.log_browser(browser)
        helpers.fullpage_screenshot(browser, Image)

        return 1
    except Exception as ex:
        logger.error(str(ex))
        return 0
Beispiel #6
0
def sign(user, password, schoolid, kidnum, Image):
    try:
        browser = helpers.GetBrowser()
        logger.info("Starting process")

        try:
            helpers.ping(browser, 'infogan')
        except:
            logger.debug('Unable to ping')
        logger.debug(
            '----------------------------------------------------------------------'
        )
        logger.info("Starting Mashov Sign process for kid number: " + kidnum)

        browser.get("https://web.mashov.info/students/login")
        time.sleep(3)

        #choose school:
        form_element_mashov_select_school = browser.find_element_by_xpath(
            "//*[@id='mat-input-3']")
        form_element_mashov_user = browser.find_element_by_xpath(
            "//*[@id='mat-input-0']")
        form_element_mashov_password = browser.find_element_by_xpath(
            "//*[@id='mat-input-4']")
        form_element_mashov_login = browser.find_element_by_xpath(
            "//*[@id='mat-tab-content-0-0']/div/div/button[1]")

        form_element_mashov_select_school.click()
        #form_element_mashov_select_school.send_keys(_convert(var_mashov_school_id)) # Moving to identify by school number instead of school name
        form_element_mashov_select_school.send_keys(schoolid)
        form_element_mashov_select_school.send_keys(Keys.ARROW_DOWN)
        form_element_mashov_select_school.send_keys(Keys.RETURN)

        form_element_mashov_user.click()
        form_element_mashov_user.send_keys(user)
        form_element_mashov_password.click()
        form_element_mashov_password.send_keys(password)
        form_element_mashov_login.click()
        time.sleep(3)

        logger.info(f"Logged in")

        form_element_mashov_select_daily_corona_report = browser.find_element_by_xpath(
            "/html/body/mshv-root/mshv-main/mat-sidenav-container/mat-sidenav-content/mshv-student-covidsplash/mat-card/mat-card-content/div[3]/mat-card"
        )
        form_element_mashov_select_daily_corona_report.click()
        time.sleep(2)

        form_element_mashov_submit_report = browser.find_element_by_xpath(
            "/html/body/mshv-root/mshv-main/mat-sidenav-container/mat-sidenav-content/mshv-students-covid-clearance/mat-card/mat-card/mat-card-content[2]/mat-card-actions/button"
        )
        if 'אני מצהיר' in form_element_mashov_submit_report.text:
            form_element_mashov_submit_report.click()

        logger.info(f"Submitted Report")
        time.sleep(1)

        helpers.log_browser(browser)
        helpers.fullpage_screenshot(browser, Image)

        logger.info(f"Screenshot Saved")
        logger.info("Finished Mashov Sign process for kid number: " + kidnum)
        logger.debug(
            '----------------------------------------------------------------------'
        )

        return 1
    except Exception as ex:
        logger.error(str(ex))
        return 0