• 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 "}"}'
  • 作业1

    $ awk '{print $7}' nginx.log | sed -E 's/[0-9]+/_d/g' | sort | uniq -c | sort -gr | head -1
    584 /cable

    作业2

    $ awk '$7~/^\/topics\// {print $(NF-1)}' nginx.log | awk '{sum+=$1} END{print "平均响应时间 :"sum/NR}'
    平均响应时间 0.101318

    $ awk '$7~/^\/topics\// && $9~/200/ {print $(NF-1)}' nginx.log | awk '{sum+=$0} END{print "响应代码为 200 的请求平均响应时间:"sum/NR}'
    响应代码为 200 的请求平均响应时间:0.191565
  • 可能是大家统计的 topics 请求数各不相同,写正则的时候混了些非 /topics/nnn 路径的请求进去了

攻城狮 && Coder && 粵語控