Example #1
0
def find_text(context, element, value, page):
    page = check_page(page)
    element = LocateHeper.get_protect_attribute(page, element)
    if LocateHeper(context.driver).find(element).get_text() != value:
        raise Exception(
            "The text of {element} is not {value} in {page}".format(
                element=element, value=value, page=page))
Example #2
0
def check_element(context, element, page):
    page = check_page(page)
    element = LocateHeper.get_protect_attribute(page, element)
    if LocateHeper(context.driver).find(element):
        pass
    else:
        context.driver.get_screenshot_as_file(
            r'/Users/tianqi/Desktop/study/Appium_UI_Autotest/Log/test.png')
        context.logger.error("找不到元素{element} in {page}".format(element=element,
                                                               page=page))
        raise Exception
Example #3
0
def swich_and_click(context, button, page):
    context.driver.switch_to_alert()
    page = check_page(page)
    button = LocateHeper.get_protect_attribute(page, button)
    LocateHeper(context.driver).find(button).click()
Example #4
0
def input_text(context, element, text, page):
    page = check_page(page)
    element = LocateHeper.get_protect_attribute(page, element)
    LocateHeper(context.driver).find(element).send_keys(text)
Example #5
0
def click_element(context, element, Page):

    page = check_page(Page)
    element = LocateHeper.get_protect_attribute(page, element)
    LocateHeper(context.driver).find(element).click()