zoukankan      html  css  js  c++  java
  • Appium + python 获取toast

    1.导入WebDriverWait、expected_conditions模块
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.support.ui import WebDriverWait

    2.在获取toast的页面,设置隐式等待,语句如下:

    备注:文字一定要正确,要不然找不到

    3.实例:
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.support.ui import WebDriverWait
    def text_publish1(self):
        """
    # 发布的文字少于10个字
    :return:
    """
    public_dict = YAML.yamlFile()[2]['publish']
    logging.info("准备发布纯文字")
    self.driver.find_element_by_xpath(public_dict['textImg_btn']).click()
    time.sleep(2)
    self.driver.find_element_by_xpath(public_dict['text_content']).
    send_keys(public_dict['send_keys5'])
    time.sleep(2)
    self.driver.find_element_by_xpath(public_dict['publish_btn']).click()
    try:
        WebDriverWait(self.driver, 2).
    until(EC.presence_of_element_located((MobileBy.XPATH,
    '//*[contains(@text,"请选择频道")]')))
            logging.info("请选择频道")
    except NoSuchElementException:
    logging.info("没有弹出提示")
    else:
    self.driver.find_element_by_xpath(public_dict['text_content']).
    send_keys(public_dict['send_keys5'+'send_keys5'])
    self.driver.find_element_by_xpath(public_dict['publish_btn']).click()
    logging.info("发布文字完成")
    time.sleep(2)
    self.driver.find_element_by_xpath(public_dict['last_tab']).click()

    备注:找到toast之后,send_keys会清除之前输入的内容重新输入,不知道为啥~~~
  • 相关阅读:
    一套测试题
    静态成员与友元
    grids2742
    [转]CentOS添加第三方yum源
    Linux软件包管理
    类的基本概念
    2012百度实习生笔试题(c++方向)
    anyview 数据结构习题集 第1章答案
    Linux常用命令
    anyview 数据结构习题集 第2章答案
  • 原文地址:https://www.cnblogs.com/keqing1108/p/12063339.html
Copyright © 2011-2022 走看看