• def test_xueqiu(self):
    query={'_t':'1UNKNOWNc60715cb4a61425b311034a49f4aa024.3446260779.1563002521424.1563005246620',
    '_s':'8c6b2d',
    'category':'1',
    'pid':'-1',
    'size':'10000',
    'x':'1.3',
    'page':'1'}

    r = requests.get('https://101.201.175.228/v5/stock/portfolio/stock/list.json',
    params=query,
    headers={'Host':'stock.xueqiu.com',
    'User-Agent':'Xueqiu Android 11.19'},
    cookies={'xq_a_token':'5806a70c6bc5d5fb2b00978aeb1895532fffe502',
    'u':'3446260779'},
    verify=False
    )
    logging.info(json.dumps(r.json(),indent=2))
  • 除了 app UI 层 功能层的兼容性测试,某些专项测试如不同网络环境的兼容性有高效的解决方案吗

  • pytest 有从整体上控制用例执行的方式吗?
    比如 testng 通过 testng.xml 管理测试套件这种方式。
    还是只能通过指定模块运行模块内测试用例,具体哪些测试方法运行或不运行需要在测试类里硬编码控制。

  • 2

  • 忽略,未开模拟点击权限

    [element.click()] Error response status: 13, UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission at android.os.Parcel.readException(Parcel.java:1692) at android.os.Parcel.readException(Parcel.java:1645) at 
  • 作业

    from appium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait


    class DriverFactory(object):
    """ Generate the caps and set up AppiumDriver. """

    def create_driver(self, platform):
    if 'Android' == platform:
    return webdriver.Remote('http://localhost:4723/wd/hub',
    self.android_caps())

    def android_caps(self):
    caps = {
    'platformName': 'Android',
    'autoGrantPermissions': 'true',
    'noReset': 'true'
    }
    caps['deviceName'] = 'vivo x9'
    caps['platformVersion'] = '7.1'
    caps['automationName'] = 'UiAutomator2'
    caps['appPackage'] = 'com.xueqiu.android'
    caps['appActivity'] = '.view.WelcomeActivityAlias'
    return caps


    class ElementUtil(object):
    """ Package element's common function. """

    def __init__(self, driver):
    self.driver = driver

    def find_element(self, timeout, locator):
    return WebDriverWait(self.driver, timeout).until(
    lambda x: x.find_element(*locator))

    def click(self, byType, locate, timeout=10):
    element = self.find_element(timeout, (byType, locate))
    element.click()
    return self

    def typing(self, byType, locate, value, timeout=10):
    element = self.find_element(timeout, (byType, locate))
    element.click() # Let the element in focus.
    element.clear()
    element.send_keys(value)
    return self


    class BasePage(ElementUtil):
    """
    Parent class for all pages.
    Extended from ElementUtil, also package page's common function.
    """

    pass


    class MainClass(object):

    if __name__ == '__main__':
    driver = DriverFactory().create_driver('Android')

    BasePage(driver) \
    .click('id', 'com.xueqiu.android:id/skip_ad') \
    .click('id', 'com.xueqiu.android:id/tv_search') \
    .typing('id', 'com.xueqiu.android:id/search_input_text'
    , 'alibaba') \
    .click('id', 'com.xueqiu.android:id/follow_btn')

    driver.quit()
  • 申请开通😀

  • 课后作业

    统计Linux上的某个进程的 cpu 增长曲线,贴出代码

    top -b -d 1 -n 10 | grep --line-buffered mysqld | awk '{print $(NF-3)}' | gnuplot -e "set terminal
    dumb;plot '<cat' using 1 with line"

    mysql 一次查表工作 cpu 增长曲线

    统计 App 上某个业务操作期间内存增长情况,贴出代码

    for i in `seq 20`;  
    do
    adb shell input swipe 540 1000 540 1500;
    adb shell dumpsys meminfo com.oray.sunlogin \
    | grep "Dalvik Heap" \
    | awk '{print $4}';
    done \
    | gnuplot -e "set terminal dumb;plot '<cat' using 1 with line"

    连续下拉列表内存变化图

  • last | grep logged | awk '{print $1}' | sort | uniq  | wc -l
  • 课后作业

    curl -s https://testerhome.com/api/v3/topics.json \
    | sed -e "s#{\"topics\"\:\[{##" -e "s#}]}##" -e "s#},{#~#g" \
    | awk -v RS="~" '$0!~/\n/{print "{" $0 "}"}'

攻城狮 && Coder && 粵語控