Ejemplo n.º 1
0
def clear(locationtype, locatorexpression, *args):
    global driver
    try:
        #获取页面元素,然后执行清除动作
        getelement(driver, locationtype, locatorexpression).clear()
    except Exception as e:
        raise e
Ejemplo n.º 2
0
def clicks(locationtype, locatorexpression, *args):
    global driver
    try:
        # 获取页面元素后执行点击动作
        getelement(driver, locationtype, locatorexpression).click()
    except Exception as e:
        raise e
Ejemplo n.º 3
0
def input_srting(locationtype, locatorexpression, inputcontent):
    global driver
    try:
        #获取页面元素后执行发送信息动作
        getelement(driver, locationtype,
                   locatorexpression).send_keys(inputcontent)

    except Exception as e:
        raise e
Ejemplo n.º 4
0
def switch_to_frame(locationtype, framelocatorexpression, *args):
    global driver
    try:
        driver.switch_to.frame(
            getelement(driver, locationtype, framelocatorexpression))
    except Exception as e:
        print('frame error')
        raise e
Ejemplo n.º 5
0
def getelemen(locatetype, locatorexpression):
    '''
    获取单个页面元素对象
    '''
    global driver
    try:
        return getelement(driver, locatetype, locatorexpression)
    except Exception as e:
        raise e
Ejemplo n.º 6
0
def assert_get_html(locationtype, assertstring):
    global driver
    try:
        #获取dom对象下所有元素和标签
        html = getelement(driver, 'xpath', '//*')
        #获取所有HTML源文件
        html_attr = str(html.get_attribute('outerHTML'))
        #获取该对象的HTML源代码
        attrbutehtml = str(locationtype.get_attribute('outerHTML'))
        #检查传入的参数是否在页面中
        assert assertstring in html_attr
        print('断言成功,页面源代码包含元素:%s,可在该代码中查看:%s' % (assertstring, attrbutehtml))
    except Exception as e:
        print(u'断言失败,页面源代码不存在 “%s” 元素,请手动检查页面!' % assertstring, e)