Exemplo n.º 1
0
def click(locationType, locatorExpression, *arg):
    #单击页面元素
    global driver
    try:
        get_element(driver, locationType, locatorExpression).click()
    except Exception as e:
        raise e
Exemplo n.º 2
0
def input_string(locationType, locatorExpression, inputContent):
    global driver
    try:
        get_element(driver, locationType,
                    locatorExpression).send_keys(inputContent)
    except Exception as e:
        raise e
Exemplo n.º 3
0
def clear(locationType, locatorExpression, *args):
    #清除输入框默认内容
    global driver
    try:
        get_element(driver, locationType, locatorExpression).clear()
    except Exception as e:
        raise e
Exemplo n.º 4
0
def getText(locationType, locatorEpression, *args):
    #获得表达式的text值,并保存至全局变量Text中
    global driver, Text
    try:
        Text = get_element(driver, locationType, locatorEpression).text
        print(Text)
        return Text
    except Exception as e:
        raise e
Exemplo n.º 5
0
def getValue(locationType, locatorExpression, *args):
    #获取选定元素的Value属性值,并保存至全局变量GValue中
    global driver, GValue
    try:
        GValue = get_element(driver, locationType,
                             locatorExpression).get_attribute("value")
        # print(GValue)
        return GValue
    except Exception as e:
        raise e
Exemplo n.º 6
0
def assertElementHtml(locationType, locatorExpression, String, *args):
    #断言选中元素源码中存在某字段
    global driver
    try:
        SourceHtml = get_element(driver, locationType,
                                 locatorExpression).get_attribute("outerHTML")
        # print(SourceHtml)
        if String in SourceHtml:
            pass
        else:
            raise Exception
    except Exception as e:
        raise e
Exemplo n.º 7
0
def assert_element_text(locationType, locatorExpression, input_value, *arg):
    #判断element_text
    global driver
    try:
        element = get_element(driver, locationType, locatorExpression)
        if element:
            value = element.text
            if value.find(input_value) != -1 or value.find(
                    Text) != -1 or value.find(GValue) != -1:
                # print(u'存在')
                pass
            else:
                # print(u'无此字段')
                raise Exception
        else:
            print(element)
            raise Exception
    except Exception as e:
        raise e