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会清除之前输入的内容重新输入,不知道为啥~~~
  • 相关阅读:
    Python如何编写一个带命令行参数的程序
    软件工程第二次作业----(1)补交
    软件工程第二次作业----
    2017软件工程第一次作业
    2017软件工程第三次作业--功能测试
    2017软件工程第三次作业--效能分析
    每周例行报告
    2017软件工程第二次作业(一)
    2017软件工程第二次作业(二)
    2017软件工程第一次作业
  • 原文地址:https://www.cnblogs.com/keqing1108/p/12063339.html
Copyright © 2011-2022 走看看