• “斯人若彩虹,遇上方知有”

    ——《怦然心动》

    这段话我觉得英文更好😃

    “Some of us get dipped in flat,some in sain,some in gloss.But every once in a while, you find someone who’s indescen.And when you do,nothing will ever compare.”

  • 上海还招人吗

  • 作业三

    • 复杂长列表上拉加载
  • @Seamus 请问下,有没有遇到导入后生成报告是空白,报错信息:
    Errors
    strconv.ParseFloat: parsing "p": invalid syntax
    could not parse aggregated battery stats
    device capacity is 0

  • Author only
  • 老师,能讲下用例分层吗,testsuit里耦合比较多

  • 有一类场景:需要根据先前接口返回结果(eg:列表)来对后续接口进行数据驱动的情况。
    请问是如何解决的

  • 作业四

    page
    search.py
    from driver.appium_driver import AppiumDriver
    from page.zixuan import ZiXuan

    class Search:

    def __init__(self):
    self.driver = AppiumDriver.get_driver()

    def search(self, keyword):
    self.driver.find_element_by_id("search_input_text").send_keys(keyword)
    return self

    def get_username(self):
    self.driver.find_element_by_xpath("//*[@text='用户']")
    return AppiumDriver.get_driver().find_element_by_id("user_name").text

    def get_stock(self):
    self.driver.find_element_by_xpath("//*[@text='股票']")
    return AppiumDriver.get_driver().find_element_by_id("stockName").text

    def add_stock(self):
    AppiumDriver.get_driver().find_element_by_xpath("//*[@text='股票']")
    if len(self.driver.find_elements_by_id("follow_btn")):
    self.driver.find_element_by_id("follow_btn").click()
    self.driver.find_element_by_id("action_close").click()

    def to_zixuan(self):
    self.driver.find_element_by_xpath(
    "//*[@text='自选' and contains(@resource-id, 'tab_name')]").click()
    return ZiXuan()
    xueqiu.py
    from driver.appium_driver import AppiumDriver
    from page.search import Search

    class XueQiu:

    def __init__(self):
    self.driver = AppiumDriver.get_driver()

    def to_search(self):
    self.driver.find_element_by_id("tv_search").click()
    return Search()
    zixuan.py
    from driver.appium_driver import AppiumDriver

    class ZiXuan:
    def __init__(self):
    self.driver = AppiumDriver.get_driver()
    testcase
    test_xueqiu.py
    import pytest
    from page.xueqiu import XueQiu
    from driver.appium_driver import AppiumDriver

    class TestXueqiu:

    @pytest.fixture(scope="function", autouse=True)
    def base_config(self):
    AppiumDriver.init_driver()

    def test_add_stock(self):
    tag_stock = "汽车之家"
    xueqiu = XueQiu()
    search = xueqiu.to_search()
    search.search(tag_stock)
    search.add_stock()
    zixuan = search.to_zixuan()
    assert tag_stock in zixuan.driver.page_source
  • 作业三

    import pytest
    from appium import webdriver
    from appium.webdriver.common.touch_action import TouchAction

    STOCKS = [
    "百度", "阿里巴巴", "腾讯", "美团", "今日头条",
    "拼多多", "饿了么", "京东", "滴滴出行", "中国平安",
    "中国联通", "中国移动", "Facebook", "Google", "大疆",
    "雅虎", "微软", "高通", "小米", "格力",
    "oppo", "vivo手机", "苹果", "美的", "恒大",
    "蚂蚁金服", "网易", "陌陌", "中国人保", "京东方"
    ]


    class TestXueqiu:
    @pytest.fixture(scope="function", autouse=True)
    def base_config(self):
    caps = {}
    caps["platformName"] = "Android"
    caps["deviceName"] = "huawei"
    caps["appActivity"] = ".view.WelcomeActivityAlias"
    caps["noReset"] = True
    caps["appPackage"] = "com.xueqiu.android"
    caps["autoGrantPermissions"] = True
    caps["unicodeKeyboard"] = True
    caps["resetKeyboard"] = True

    self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
    self.driver.implicitly_wait(6)

    def add_stock(self, stockName):
    '''
    添加股票
    :return:
    '''
    self.driver.find_element_by_id("tv_search").click()
    self.driver.find_element_by_id(
    "search_input_text").send_keys(stockName)
    if len(self.driver.find_elements_by_id("follow_btn")):
    self.driver.find_element_by_id("follow_btn").click()

    def find_stock(self, stockName):
    '''
    递归查找股票
    :param stockName: 股票名
    :return:
    '''
    screen_width = self.driver.get_window_size()["width"]
    screen_height = self.driver.get_window_size()["height"]
    stocks = self.driver.find_elements_by_id("portfolio_stockName")
    stocklist = []
    for stock in stocks:
    stocklist.append(stock.text)
    if stockName in stocklist:
    return stockName
    else:
    self.driver.swipe(
    1 / 2 * screen_width,
    1 / 2 * screen_height,
    1 / 2 * screen_width,
    1 / 7 * screen_height,
    duration=1000)
    return self.find_stock(stockName)

    def test_add_us(self):
    '''
    添加一只美股,判断是否添加成功
    :return:
    '''
    self.add_stock("汽车之家")
    self.driver.find_element_by_id("action_close").click()
    self.driver.find_element_by_xpath(
    "//*[@text='自选' and contains(@resource-id, 'tab_name')]").click()
    self.driver.find_element_by_xpath("//*[@text='美股']").click()
    assert self.driver.find_elements_by_xpath("//*[@text='汽车之家']")

    def test_delete_us(self):
    '''
    然后删除一只美股,判断删除成功
    :return:
    '''
    self.driver.find_element_by_xpath(
    "//*[@text='自选' and contains(@resource-id, 'tab_name')]").click()
    self.driver.find_element_by_xpath("//*[@text='美股']").click()
    element = self.driver.find_element_by_xpath("//*[@text='汽车之家']")
    if element:
    TouchAction(self.driver).long_press(element).perform()
    self.driver.find_element_by_xpath("//*[@text='删除']").click()
    assert 0 == len(
    self.driver.find_elements_by_xpath("//*[@text='汽车之家']"))

    @pytest.mark.parametrize("stocks", STOCKS)
    def test_add_batch(self, stocks):
    '''
    利用参数化或者数据驱动添加30只股票
    :param stocks:
    :return:
    '''
    self.add_stock(stocks)

    def test_exist_in_all(self):
    '''
    当全部股票大于2页的时候断言某个股票同时存在于“美股”与“全部”分类中
    :return:
    '''
    self.driver.find_element_by_xpath(
    "//*[@text='自选' and contains(@resource-id, 'tab_name')]").click()
    tag_stock = "百度"
    in_all_bar = self.find_stock(tag_stock)
    self.driver.find_element_by_xpath("//*[@text='美股']").click()
    in_us_bar = self.find_stock(tag_stock)
    assert in_all_bar and in_us_bar