示例#1
0
def login():
    login_fps('*****@*****.**', '123123123')
    # 获取登录后用户昵称
    nickname = driver.find_element_by_xpath(
        '/html/body/div[3]/header/div/div[2]/div[1]/div[1]/dl/dt/a[2]/span'
    ).text
    # 更新数据库中实际获取到的用户昵称
    update_output(nickname, 1)
    # 校验期望与实际是否一致
    result(1)
示例#2
0
def equal(method, a, b):
    expect = list()
    actual = list()
    if len(a) == len(b) and len(b) > 0:
        for i, j in zip(a, b):
            for x in range(len(i) if len(i) < len(j) else len(j)):
                c = str(i[x]).replace('"', '').replace(' ', '').replace(
                    '\xe2\x80\x8b', '')  # 处理双引号,空格,看不见的空白
                d = str(j[x]).replace('"', '').replace(' ', '').replace(
                    '\xe2\x80\x8b', '')
                expect.append(c)
                actual.append(d)
                if c != d:
                    print(u'test', c.encode('gbk', 'ignore'),
                          d.encode('gbk', 'ignore'))
    else:
        expect.append('f**k')
        actual.append('fuck_off')
    update_output(method, ','.join(expect), ','.join(actual))
示例#3
0
def Search_fans(driver):
    username = '******'
    password = '******'
    login.login_fps(username, password)
    time.sleep(3)
    driver.find_element_by_xpath(
        '/html/body/div[1]/div[2]/div/div/div/div/div[3]/div/ul/li[1]/a/span[1]'
    ).click()
    time.sleep(2)
    # 搜索好友
    driver.find_element_by_xpath('//*[@id="search-text"]/input').send_keys('S')
    time.sleep(3)
    driver.find_element_by_id('search-submit').click()
    time.sleep(3)
    if driver.find_elements_by_link_text('Sundy'):
        print('搜索成功')
        actual = 'Sundy'

    update_output('FPS_011', 'Sundy', actual)
示例#4
0
def login_lps(username, password):
    base_url = "http://q.dev.com/"
    driver = Driver.driver_init()
    try:
        driver.get(base_url)
        driver.find_element_by_xpath(
            "//*[@id=\"microoh-navbar-collapse\"]/div[1]/div/a[1]").click()
        driver.find_element_by_id("id_account_l").send_keys(username)
        driver.find_element_by_id("id_password_l").send_keys(password)
        driver.find_element_by_id("login_btn").click()
        actual = driver.find_element_by_xpath(
            "/html/body/div[3]/header/div/div[2]/div[1]/div[1]/dl/dt/a[2]/span"
        ).text
    except Exception:
        actual = u'找不到元素'

    expect = data('lps_lilang',
                  'mz_user_userprofile', ['nick_name'],
                  username=username)[0][0]
    update_output('login_lps', actual, expect)
示例#5
0
def setting(driver):
    username = '******'
    password = '******'
    login.login_fps(username, password)
    time.sleep(5)
    driver.find_element_by_link_text('个人设置').click()
    time.sleep(5)
    driver.find_element_by_xpath(
        '//*[@id="user_info_save"]/div[1]/div/span[3]/a').click()
    driver.find_element_by_id("file_upload").send_keys("E:\\Pictures\\lyp.jpg")
    time.sleep(5)
    driver.find_element_by_xpath(
        '//*[@id="upload-pane"]/div[2]/button').click()
    time.sleep(3)
    driver.find_element_by_id('id_nick_name').clear()
    time.sleep(3)
    driver.find_element_by_id('id_nick_name').send_keys(u'漆来平猪')
    driver.find_element_by_id('id_position').clear()
    time.sleep(3)
    driver.find_element_by_id('id_position').send_keys(u'测试工程师猪')
    time.sleep(2)
    driver.find_element_by_id('id_description').clear()
    driver.find_element_by_id('id_description').send_keys(u'打酱油工程师')
    js = "document.body.scrollTop=10000;"
    driver.execute_script(js)

    time.sleep(2)
    driver.find_element_by_id('id_qq').clear()
    driver.find_element_by_id('id_qq').send_keys('123456')
    time.sleep(2)

    driver.find_element_by_id('user_save').click()
    time.sleep(2)

    actual = select(
        'select nickname from mz_forum_entity where user=2218 order BY date_publish  DESC limit 0,1 ;'
    )
    print(actual)

    update_output('FPS_010', '漆来平猪', actual)
示例#6
0
def publish_article(tile, content):
    # 跳转文章页面
    time.sleep(3)
    driver.get("http://192.168.1.142/group/article")
    time.sleep(3)
    # 点击发布文章按钮
    driver.find_element_by_xpath(
        "/html/body/div[3]/div[2]/div/div/div[2]/a").click()
    # 输入文章内容
    driver.find_element_by_id("id_title").send_keys(tile)
    driver.switch_to_frame("ueditor_0")
    driver.find_element_by_xpath("/html/body").send_keys(content)
    driver.switch_to.default_content()
    time.sleep(1)
    # 选择文章图片
    driver.find_element_by_xpath(
        "/html/body/div[1]/div[2]/div/div/div[1]/div/div/div[2]/form/div[3]/div/a"
    ).click()
    time.sleep(1)
    driver.find_element_by_id("file_upload").send_keys(
        "D:\\Pictures\\1231211321lilang.jpg")
    driver.find_element_by_xpath(
        "/html/body/div[1]/div[3]/div/div/div/div/div[2]/div/div[2]/button"
    ).click()
    time.sleep(1)
    # 点击发布按钮
    driver.find_element_by_xpath(
        "/html/body/div[1]/div[2]/div/div/div[1]/div/div/div[2]/form/div[7]/div/button"
    ).click()
    # 校验该用户最新的文章是否和刚才发布的一致
    conn2 = fps_conn().cursor()
    conn2.execute(
        'select title,content,date_publish from mz_forum_entity where user=2218  order by date_publish desc limit 1'
    )
    out_put = conn2.fetchall()
    update_output(out_put[0][0] + out_put[0][1] + out_put[0][2], 2)
    result(2)