Beispiel #1
0
def pageStatus():
    option = webdriver.ChromeOptions()
    option.add_argument('disable-infobars')
    # 不打开浏览器
    option.add_argument('--headless')
    option.add_argument('--disable-gpu')
    driver = webdriver.Chrome(options=option)
    driver.implicitly_wait(10)
    ret = 0
    msgError = ''
    if (login.run(driver)):
        log.e('登陆失败')
        ret = 1
        msgError = msgError + "crm登陆失败\n"
    if toThird.run(driver, config.caseCompanyName, config.caseTaxId):
        log.e('进账簿失败')
        ret = 1

        msgError = msgError + "进账簿失败\n"

    if loginNew.run(driver):
        log.e('第三方跳转登陆失败')

        ret = 1
        msgError = msgError + "第三方跳转登录失败\n"

    return ret, msgError
        r = requests.get(driver.current_url, allow_redirects=False)
        log.exception('录入凭证异常', r.status_code)
        return 1


if __name__ == "__main__":
    print('main')
    # config.set_host(config.HOST_SOURCE_PRE)
    if (config.hostSource == None):
        log.e('未设置数据源')
    else:
        option = webdriver.ChromeOptions()
        option.add_argument('disable-infobars')
        driver = webdriver.Chrome(options=option)
        driver.set_window_size(config.window_size_w, config.window_size_h)
        driver.implicitly_wait(5)
        ret = loginNew.run(driver)
        if (ret != 0):

            print('登陆失败')
            time.sleep(config.FAIL_WAIT_SLEEP)
            driver.quit()
        else:
            ret = run(driver)
            if (ret != 0):
                log.e('凭证录入失败', ret)
                time.sleep(config.FAIL_WAIT_SLEEP)

            time.sleep(5)
            driver.quit()