不晓得是不是因为之前出过书的原因,在写教程之类的文章,会潜意识有自带目次和章节的觉得在里面,有点说不出的觉得吧。
上篇文章我们介绍了关于元素定位的利用办法,那篇文章将为各人分享关于Minium中Minium、App模块的API 利用。
常用API利用详解get_system_info()❝
获取系统信息
❞
shutdown()❝
测试完毕时挪用, 停行 微信开发者IDE 以及 minium, 并收受接管资本。一般供测试框架挪用
❞
screen_shot()❝
截图
❞
ide上仅能截取到wxml页面的内容,Modal/Actionsheet/受权弹窗等无法截取
「Parameters:」
名称 类型 默认值 申明 save_path str Not None 截图保留途径 format str raw 截图数据返回格局,raw 或者 pillow
「示例代码如下:」
def test_screen_shot(self): """ 截图操做 :return: """ output_path = os.path.join(os.path.dirname(__file__), "outputs/test_screen_shot.png") PRint(output_path) if not os.path.isdir(os.path.dirname(output_path)): os.mkdir(os.path.dirname(output_path)) if os.path.isfile(output_path): os.remove(output_path) ret = self.app.screen_shot(output_path) # 截图并存到`output_path`文件夹中 self.assertTrue(os.path.isfile(output_path))evaluate()❝
向 app Service 层注入代码并施行
❞
❝
实机调试2.0下, 注入的代码只撑持es5的语法
❞
「Parameters:」
名称 类型 默认值 申明 app_function str Not None 代码字符串 args list Not None 参数 sync bool False 能否同步施行
「Returns:」
sync == True: dict(result={"result": 函数返回值})sync == False: str(动静ID)。共同get_async_response用获取返回值「示例代码如下:」
import minium# sync == True@minium.ddt_classclass TestApp(minium.MiniTest): @minium.ddt_case([], ["1", "2"]) def test_evaluate_sync(self, args): result = self.app.evaluate( "function(){args=arguments;return 'test evaluate: '.concat(Array.from(args));}", args, sync=True ) self.assertEqual( result.get("result", {}).get("result"), "test evaluate: {}".format(",".join(args)) )get_async_response()❝
获取evaluate办法异步伐用的成果
❞
「Parameters:」
名称 类型 默认值 申明 msg_id str Not None evaluate返回的动静ID timeout int None 期待超不时间,None: 立即返回
「示例代码如下:」
import minium# sync == False@minium.ddt_classclass TestApp(minium.MiniTest): @minium.ddt_case([], ["1", "2"]) def test_evaluate_async(self, args): msg_id = self.app.evaluate( "function(){args=arguments;return 'test evaluate: '.concat(Array.from(args));}", args, sync=False ) # 你能够做一些其他操做后, 再通过get_async_response办法获取前面注入代码的运行成果 result = self.app.get_async_response(msg_id, 5) self.assertEqual( result.get("result", {}).get("result"), "test evaluate: {}".format(",".join(args)) )get_all_pages_path()❝
获取所有已设置装备摆设的页面途径
❞
「Returns:」
list「示例代码如下:」
def test_get_all_pages_path(self): """ 获取所有已设置装备摆设的页面途径 :return:list """ all_pages_path = self.app.get_all_pages_path() self.assertListEqual( ['page/component/index', 'page/API/index', 'page/cloud/index', 'page/extend/index', 'page/animation/index', 'packageComponent/pages/view/view/view', 'packageComponent/pages/view/scroll-view/scroll-view', 'packageComponent/pages/view/swiPEr/swiper', 'packageComponent/pages/view/movable-view/movable-view', 'packageComponent/pages/view/cover-view/cover-view', 'packageComponent/pages/content/text/text', 'packageComponent/pages/content/icon/icon', 'packageComponent/pages/content/progress/progress', 'packageComponent/pages/content/rich-text/rich-text', 'packageComponent/pages/form/button/button', 'packageComponent/pages/form/checkbox/checkbox', 'packageComponent/pages/form/form/form', 'packageComponent/pages/form/input/input', 'packageComponent/pages/form/label/label', 'packageComponent/pages/form/picker/picker', 'packageComponent/pages/form/picker-view/picker-view', 'packageComponent/pages/form/radio/radio', 'packageComponent/pages/form/slider/slider', 'packageComponent/pages/form/switch/switch', 'packageComponent/pages/form/textarea/textarea', 'packageComponent/pages/form/editor/editor', 'packageComponent/pages/nav/navigator/navigator', 'packageComponent/pages/nav/navigator/navigate', 'packageComponent/pages/nav/navigator/redirect', 'packageComponent/pages/media/image/image', 'packageComponent/pages/media/video/video', 'packageComponent/pages/media/camera/camera', 'packageComponent/pages/media/live-pusher/live-pusher', 'packageComponent/pages/media/live-player/live-player', 'packageComponent/pages/map/map/map', 'packageComponent/pages/canvas/canvas-2d/canvas-2d', 'packageComponent/pages/canvas/webgl/webgl', 'packageComponent/pages/open/ad/ad', 'packageComponent/pages/open/open-data/open-data', 'packageComponent/pages/open/web-view/web-view', 'packageComponent/pages/obstacle-free/aria-component/aria-component', 'packageComponent/pages/doc-web-view/doc-web-view', 'packageAPI/pages/api/login/login', 'packageAPI/pages/api/get-user-info/get-user-info', 'packageAPI/pages/api/request-payment/request-payment', 'packageAPI/pages/api/jump/jump', 'packageAPI/pages/api/share/share', 'packageAPI/pages/api/share-button/share-button', 'packageAPI/pages/api/custom-message/custom-message', 'packageAPI/pages/api/subscribe-message/subscribe-message', 'packageAPI/pages/api/choose-address/choose-address', 'packageAPI/pages/api/choose-invoice-title/choose-invoice-title', 'packageAPI/pages/api/soter-authentication/soter-authentication', 'packageAPI/pages/api/setting/setting', 'packageAPI/pages/ar/visionkit-basic/visionkit-basic', 'packageAPI/pages/ar/visionkit-basic-v2/visionkit-basic-v2', 'packageAPI/pages/ar/plane-ar/plane-ar', 'packageAPI/pages/ar/plane-ar-v2/plane-ar-v2', 'packageAPI/pages/ar/plane-ar-3dof/plane-ar-3dof', 'packageAPI/pages/ar/2dmarker-ar/2dmarker-ar', 'packageAPI/pages/ar/3dmarker-ar/3dmarker-ar', 'packageAPI/pages/ar/osd-ar/osd-ar', 'packageAPI/pages/ar/face-detect/face-detect', 'packageAPI/pages/ar/body-detect/body-detect', 'packageAPI/pages/ar/hand-detect/hand-detect', 'packageAPI/pages/ar/ocr-detect/ocr-detect', 'packageAPI/pages/ar/photo-ocr-detect/photo-ocr-detect', 'packageAPI/pages/ar/photo-hand-detect/photo-hand-detect', 'packageAPI/pages/ar/photo-body-detect/photo-body-detect', 'packageAPI/pages/ar/photo-face-detect/photo-face-detect', 'packageAPI/pages/page/set-navigation-bar-title/set-navigation-bar-title', 'packageAPI/pages/page/navigation-bar-loading/navigation-bar-loading', 'packageAPI/pages/page/navigator/navigator', 'packageAPI/pages/page/pull-down-refresh/pull-down-refresh', 'packageAPI/pages/page/animation/animation', 'packageAPI/pages/page/action-sheet/action-sheet', 'packageAPI/pages/page/modal/modal', 'packageAPI/pages/page/toast/toast', 'packageAPI/pages/page/canvas/canvas', 'packageAPI/pages/page/get-wxml-node-info/get-wxml-node-info', 'packageAPI/pages/page/page-scroll/page-scroll', 'packageAPI/pages/page/intersection-observer/intersection-observer', 'packageAPI/pages/device/clipboard-data/clipboard-data', 'packageAPI/pages/device/bluetooth/bluetooth', 'packageAPI/pages/device/bluetooth/slave/slave', 'packageAPI/pages/device/screen-brightness/screen-brightness', 'packageAPI/pages/device/vibrate/vibrate', 'packageAPI/pages/device/add-contact/add-contact', 'packageAPI/pages/device/wifi/wifi', 'packageAPI/pages/device/get-network-type/get-network-type', 'packageAPI/pages/device/on-network-status-change/on-network-status-change', 'packageAPI/pages/device/get-system-info/get-system-info', 'packageAPI/pages/device/on-compass-change/on-compass-change', 'packageAPI/pages/device/make-phone-call/make-phone-call', 'packageAPI/pages/device/scan-code/scan-code', 'packageAPI/pages/device/on-accelerometer-change/on-accelerometer-change', 'packageAPI/pages/device/capture-screen/capture-screen', 'packageAPI/pages/device/ibeacon/ibeacon', 'packageAPI/pages/device/get-battery-info/get-battery-info', 'packageAPI/pages/media/image/image', 'packageAPI/pages/media/voice/voice', 'packageAPI/pages/media/file/file', 'packageAPI/pages/media/load-font-face/load-font-face', 'packageAPI/pages/media/background-audio/background-audio', 'packageAPI/pages/media/video/video', 'packageAPI/pages/media/audio/audio', 'packageAPI/pages/media/media-container/media-container', 'packageAPI/pages/location/get-location/get-location', 'packageAPI/pages/location/open-location/open-location', 'packageAPI/pages/location/choose-location/choose-location', 'packageAPI/pages/network/request/request', 'packageAPI/pages/network/web-socket/web-socket', 'packageAPI/pages/network/upload-file/upload-file', 'packageAPI/pages/network/download-file/download-file', 'packageAPI/pages/network/mdns/mdns', 'packageAPI/pages/network/udp-socket/udp-socket', 'packageAPI/pages/storage/storage/storage', 'packageAPI/pages/storage/get-background-fetch-data/get-background-fetch-data', 'packageAPI/pages/storage/get-background-prefetch-data/get-background-prefetch-data', 'packageAPI/pages/performance/get-performance/get-performance', 'packageAPI/pages/worker/worker/worker', 'packageAPI/pages/framework/two-way-bindings/two-way-bindings', 'packageAPI/pages/framework/wxs/wxs', 'packageAPI/pages/framework/resizable/resizable', 'packageAPI/pages/framework/wxs/movable', 'packageAPI/pages/framework/wxs/sidebar', 'packageAPI/pages/framework/wxs/stick-top', 'packageAPI/pages/framework/wxs/nearby', 'packageAPI/pages/ai/mobilenet/index', 'packageAPI/pages/ai/style-trans/index', 'packageCloud/pages/user/user-authentication/user-authentication', 'packageCloud/pages/database/crud/crud', 'packageCloud/pages/database/db-permission/db-permission', 'packageCloud/pages/database/server-date/server-date', 'packageCloud/pages/storage/upload-file/upload-file', 'packageCloud/pages/storage/download-file/download-file', 'packageCloud/pages/storage/get-temp-file-url/get-temp-file-url', 'packageCloud/pages/storage/delete-file/delete-file', 'packageCloud/pages/storage/cloud-file-component/cloud-file-component', 'packageCloud/pages/scf/get-wx-context/get-wx-context', 'packageCloud/pages/scf/scf-database/scf-database', 'packageCloud/pages/scf/scf-storage/scf-storage', 'packageCloud/pages/scf/scf-openapi/scf-openapi', 'packageExtend/pages/form/cell/cell', 'packageExtend/pages/form/slideview/slideview', 'packageExtend/pages/form/form/form', 'packageExtend/pages/form/uploader/uploader', 'packageExtend/pages/base/article/article', 'packageExtend/pages/base/icons/icons', 'packageExtend/pages/base/badge/badge', 'packageExtend/pages/base/flex/flex', 'packageExtend/pages/base/footer/footer', 'packageExtend/pages/base/gallery/gallery', 'packageExtend/pages/base/grid/grid', 'packageExtend/pages/base/loadmore/loadmore', 'packageExtend/pages/base/loading/loading', 'packageExtend/pages/base/panel/panel', 'packageExtend/pages/base/preview/preview', 'packageExtend/pages/operate/dialog/dialog', 'packageExtend/pages/operate/msg/msg', 'packageExtend/pages/operate/msg/msg_success', 'packageExtend/pages/operate/msg/msg_text', 'packageExtend/pages/operate/msg/msg_text_primary', 'packageExtend/pages/operate/msg/msg_fail', 'packageExtend/pages/operate/half-screen-dialog/half-screen-dialog', 'packageExtend/pages/operate/actionsheet/actionsheet', 'packageExtend/pages/operate/toptips/toptips', 'packageExtend/pages/navigation/navigation/navigation', 'packageExtend/pages/navigation/tabbar/tabbar', 'packageExtend/pages/search/searchbar/searchbar', 'packageExtend/pages/extend/emoji/emoji', 'packageExtend/pages/extend/video-swiper/video-swiper', 'packageExtend/pages/extend/index-list/index-list', 'packageExtend/pages/extend/recycle-view/recycle-view', 'packageExtend/pages/extend/sticky/sticky', 'packageExtend/pages/extend/tabs/tabs', 'packageExtend/pages/extend/vtabs/vtabs', 'packageExtend/pages/extend/barrage/barrage', 'packageExtend/pages/extend/select-text/select-text', 'packageExtend/pages/extend/wxml-to-canvas/wxml-to-canvas', 'packageExtend/pages/adapt/telescopic/telescopic', 'packageExtend/pages/adapt/linebreak/linebreak', 'packageExtend/pages/adapt/sidenavigation/sidenavigation', 'packageExtend/pages/adapt/pagination/pagination', 'packageExtend/pages/adapt/freelaYOUt/freelayout', 'packageExtend/pages/adapt/layeredpresentation/layeredpresentation', 'packageExtend/pages/adapt/horizontalexpansion/horizontalexpansion', 'packageSkyline/pages/worklet/animation/index', 'packageSkyline/pages/worklet/gesture/index', 'packageSkyline/pages/worklet/bottom-sheet/index', 'packageSkyline/pages/share-element/list/index', 'packageSkyline/pages/share-element/card/index', 'packageSkyline/pages/half-page/scale-page/index', 'packageSkyline/pages/half-page/half-page/index', 'packageSkyline/pages/address-book/index', 'packageSkyline/pages/half-screen/index', 'packageSkyline/pages/tabs/index', 'packageSkyline/pages/album/index', 'packageSkyline/pages/preview/index', 'packageSkyline/pages/custom-route/index', 'packageSkyline/pages/custom-route/detail', 'packageSkyline/pages/scroll-view/index', 'packageXRFrame/pages/index/index', 'packageXRFrame/pages/scene-basic/index', 'packageXRFrame/pages/scene-basic-light/index', 'packageXRFrame/pages/scene-basic-animation/index', 'packageXRFrame/pages/scene-basic-particle/index', 'packageXRFrame/pages/scene-basic-touch/index', 'packageXRFrame/pages/scene-basic-visible-layer/index', 'packageXRFrame/pages/scene-basic-shadow/index', 'packageXRFrame/pages/scene-basic-video/index', 'packageXRFrame/pages/scene-basic-render-texture/index', 'packageXRFrame/pages/scene-basic-postprocessing/index', 'packageXRFrame/pages/scene-gltf-damageHelmet/index', 'packageXRFrame/pages/scene-gltf-unlit/index', 'packageXRFrame/pages/scene-gltf-animation/index', 'packageXRFrame/pages/scene-gltf-morph/index', 'packageXRFrame/pages/scene-gltf-light-loading/index', 'packageXRFrame/pages/scene-ar-basic/index', 'packageXRFrame/pages/scene-ar-2dmarker/index', 'packageXRFrame/pages/scene-ar-osdmarker/index', 'packageXRFrame/pages/scene-ar-camera/index', 'packageXRFrame/pages/scene-ar-face/index', 'packageXRFrame/pages/scene-ar-hand/index', 'packageXRFrame/pages/scene-ar-body/index', 'packageXRFrame/pages/scene-custom-logic/index', 'packageXRFrame/pages/scene-custom-render/index', 'packageXRFrame/pages/scene-scan-render/index', 'packageXRFrame/pages/scene-scan-team/index', 'packageXRFrame/pages/scene-classic-wxball/index', 'packageXRFrame/pages/scene-classic-video/index', 'packageXRFrame/pages/scene-classic-perspect/index', 'packageXRFrame/pages/scene-classic-portal/index', 'packageXRFrame/pages/scene-classic-osd/index', 'packageXRFrame/pages/scene-classic-face/index', 'packageXRFrame/pages/scene-last-record/index'], all_pages_path, "test ok", )get_current_page()❝
获取当前顶层页面
❞
「Returns:」
页面临象「示例代码如下:」
import miniumclass AppTest(minium.MiniTest): def test_get_current_page(self): page = self.app.get_current_page() # 同self.app.current_page self.assertIsNotNone(page.path) self.assertNotEqual("", page.path) print(page.path)go_home()❝
跳转到小法式首页
❞
「示例代码如下:」
def test_go_home(self): """ 跳转到小法式首页 :return: """ self.page.get_element("view", inner_text="视图容器").click() self.page.get_element("navigator", inner_text="view").click() # 跳转到小法式首页 self.app.go_home()navigate_to()❝
以导航的体例跳转到指定页面
❞
不克不及跳到 tabbar 页面。撑持相对途径和绝对途径, 小法式中页面栈最多十层
「Parameters:」
名称 类型 默认值 申明 url str Not None 页面途径 params dict None 页面参数 is_wait_url_change bool True 能否期待新的页面跳转
小我觉得就是跳转到指定页面,也能够理解为导航栏上的超链接领路径那种的
「示例代码如下:」
def test_navigate_to(self): """ 跳转到指定页面 :return: """ pass_page = self.app.get_current_page() self.app.navigate_to("/packageComponent/pages/view/view/view")navigate_back()❝
封闭当前页面,返回上一页面
❞
「示例代码如下:」
def test_navigate_to(self): """ 返回上一页 :return: """ pass_page = self.app.get_current_page() # 跳转到指定页面 self.app.navigate_to("/packageComponent/pages/view/view/view") # 返回上一页 self.app.navigate_back()redirect_to()❝
封闭当前页面,重定向到应用内的某个页面
❞
不允许跳转到 tabbar 页面
「Parameters:」
名称 类型 默认值 申明 url str Not None 页面途径 params dict None 页面参数 is_wait_url_change bool True 能否期待新的页面跳转
小我觉得同navigate_to()用法很像,各类细节感兴趣的同窗能够自行测验考试。
「示例代码如下:」
def redirect_to(self): """ 重定向到指定页面 :return: """ # 重定向到指定页面 self.app.redirect_to("/packageComponent/pages/view/view/view")relaunch()❝
封闭所有页面,翻开到应用内的某个页面
❞
「Parameters:」
名称 类型 默认值 申明 url str Not None 页面途径
「示例代码如下:」
def test_relaunch(self): """ 封闭所有页面,翻开到应用内的某个页面 :return: """ pass_page = self.app.get_current_page() # 重定向到指定页面 self.app.redirect_to("/packageComponent/pages/view/view/view") # 封闭所有页面,翻开到应用内的某个页面 self.app.relaunch("/packageComponent/pages/view/movable-view/movable-view")switch_tab()❝
跳转到 tabBar 页面
❞
会封闭其他所有非tabBar页面
「Parameters:」
名称 类型 默认值 申明 url str Not None 需要跳转的 tabBar 页面的途径(需在 app.json 的 tabBar 字段定义的页面),途径后不克不及带参数 is_click bool False 切换tab的时候触发一次onTabItemTap
「示例代码如下:」
def switch_tab(self): """ 跳转到 tabBar 页面 :return: """ pass_page = self.app.get_current_page() print(pass_page) # 重定向到指定页面 self.app.redirect_to("/packageComponent/pages/view/view/view") # 封闭所有页面,翻开到应用内的某个页面 self.app.relaunch("/packageComponent/pages/view/movable-view/movable-view") # 跳转到 tabBar 页面 self.app.switch_tab("/page/API/index")「什么是tabbar页面?」
举个栗子,好比我们小法式的底部有图标加文字的几个按钮,每个按钮对应一个页面,而整个小法式中有良多页面,小法式底部图标加文字对应的几个页面是tabbar页面,那个在app.json中有设置。 eg:在app.json中设置对应的tabbar页面
"tabBar": { "color": "#333", "selecteDColor": "#d43c33", "backgroundColor": "#fff", "position": "bottom", "list": [ { "pagePath": "pages/index/index", "text": "主页", "iconPath": "/static/images/tabs/tab-home.png", "selectedIconPath": "/static/images/tabs/tab-home-current.png" }, { "pagePath": "pages/video/video", "text": "视频", "iconPath": "/static/images/tabs/select.png", "selectedIconPath": "/static/images/tabs/selected.png" }, { "pagePath": "pages/personal/personal", "text": "小我中心", "iconPath": "/static/images/tabs/tab-my.png", "selectedIconPath": "/static/images/tabs/tab-my-current.png" } ] }get_perf_time()❝
查询小法式的性能目标,跟stop_get_perf_time配对利用
❞
「Parameters:」
名称 类型 默认值 申明 entry_types list Not None 可选项为['render', 'script', 'navigation', 'loadPackage']中的1个或多个
stop_get_perf_time()❝
完毕查询,跟get_perf_time配对利用
❞
「示例代码如下:」
def test_get_perf_time(self): """ 查询小法式的性能目标 :return: """ self.app.get_perf_time(entry_types=["navigation"]) self.app.navigate_to("/packageComponent/pages/view/view/view") self.app.redirect_to("/packageComponent/pages/view/movable-view/movable-view") perf_data = self.app.stop_get_perf_time() print(perf_data)能够看到一些途径跳转的耗时,成果如下:
[{ 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063419, 'duration': 387, 'navigationType': 'navigateTo', 'path': 'packageComponent/pages/view/view/view', 'pageId': 53, 'referrerPath': 'page/component/index', 'referrerPageId': 52, 'navigationStart': 1674803063575}, { 'entryType': 'render', 'name': 'firstRender', 'startTime': 1674803063575, 'duration': 74, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53, 'viewLayerReadyTime': 1674803063618, 'initDataSendTime': 1674803063603, 'initDataRecvTime': 1674803063619, 'viewLayerRenderStartTime': 1674803063619, 'viewLayerRenderEndTime': 1674803063646}, { 'entryType': 'render', 'name': 'firstPaint', 'startTime': 1674803063583, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'render', 'name': 'firstContentfulPaint', 'startTime': 1674803063667, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'render', 'name': 'largestContentfulPaint', 'startTime': 1674803063667, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063419, 'duration': 387, 'navigationType': 'navigateTo', 'path': 'packageComponent/pages/view/view/view', 'pageId': 53, 'referrerPath': 'page/component/index', 'referrerPageId': 52, 'navigationStart': 1674803063575}, { 'entryType': 'render', 'name': 'firstRender', 'startTime': 1674803063575, 'duration': 74, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53, 'viewLayerReadyTime': 1674803063618, 'initDataSendTime': 1674803063603, 'initDataRecvTime': 1674803063619, 'viewLayerRenderStartTime': 1674803063619, 'viewLayerRenderEndTime': 1674803063646}, { 'entryType': 'render', 'name': 'firstPaint', 'startTime': 1674803063583, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'render', 'name': 'firstContentfulPaint', 'startTime': 1674803063667, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'render', 'name': 'largestContentfulPaint', 'startTime': 1674803063667, 'path': 'packageComponent/pages/view/view/view', 'pageId': 53}, { 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063419, 'duration': 387, 'navigationType': 'navigateTo', 'path': 'packageComponent/pages/view/view/view', 'pageId': 53, 'referrerPath': 'page/component/index', 'referrerPageId': 52, 'navigationStart': 1674803063575}, { 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063874, 'duration': 680, 'navigationType': 'redirectTo', 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54, 'referrerPath': 'packageComponent/pages/view/view/view', 'referrerPageId': 53, 'navigationStart': 1674803064353}, { 'entryType': 'render', 'name': 'firstRender', 'startTime': 1674803064353, 'duration': 71, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54, 'viewLayerReadyTime': 1674803064393, 'initDataSendTime': 1674803064367, 'initDataRecvTime': 1674803064375, 'viewLayerRenderStartTime': 1674803064394, 'viewLayerRenderEndTime': 1674803064421}, { 'entryType': 'render', 'name': 'firstPaint', 'startTime': 1674803064358, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'render', 'name': 'firstContentfulPaint', 'startTime': 1674803064425, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'render', 'name': 'largestContentfulPaint', 'startTime': 1674803064425, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063874, 'duration': 680, 'navigationType': 'redirectTo', 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54, 'referrerPath': 'packageComponent/pages/view/view/view', 'referrerPageId': 53, 'navigationStart': 1674803064353}, { 'entryType': 'render', 'name': 'firstRender', 'startTime': 1674803064353, 'duration': 71, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54, 'viewLayerReadyTime': 1674803064393, 'initDataSendTime': 1674803064367, 'initDataRecvTime': 1674803064375, 'viewLayerRenderStartTime': 1674803064394, 'viewLayerRenderEndTime': 1674803064421}, { 'entryType': 'render', 'name': 'firstPaint', 'startTime': 1674803064358, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'render', 'name': 'firstContentfulPaint', 'startTime': 1674803064425, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'render', 'name': 'largestContentfulPaint', 'startTime': 1674803064425, 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54}, { 'entryType': 'navigation', 'name': 'route', 'startTime': 1674803063874, 'duration': 680, 'navigationType': 'redirectTo', 'path': 'packageComponent/pages/view/movable-view/movable-view', 'pageId': 54, 'referrerPath': 'packageComponent/pages/view/view/view', 'referrerPageId': 53, 'navigationStart': 1674803064353}]wait_for_page()❝
期待页面跳转胜利
❞
「Parameters:」
名称 类型 默认值 申明 page_path str Not None 需要期待的页面途径, 需要绝对途径, 如/pages/index
「示例代码如下:」
def test_wait_for_page(self): """ 期待页面跳转胜利 :return:布尔类型 """ self.page.get_element("view",inner_text='表单组件').click() el = self.app.current_page.get_element('navigator',inner_text='button') el.tap() current_page=self.app.get_current_page() time.sleep(3) print(current_page) ret = self.app.wait_for_page("/packageComponent/pages/form/button/button") print(ret) self.assertTrue(ret, "wait success") self.assertEqual(self.app.current_page.path, "/packageComponent/pages/form/button/button", "path ok")wait_util()❝
指按时间内, 剩余没有完成的异步恳求数 <= {cnt}个, 此时认为页面异步加载完成
❞
「Parameters:」
名称 类型 默认值 申明 cnt int Not None 剩余的异步恳求个数 max_timeout int 10 更大期待时间
「示例代码如下:」
def test_wait_util(self): """ 确定指按时间内, 异步恳求能否完成的 :return:布尔类型 """ self.page.get_element("view",inner_text='表单组件').click() el = self.app.current_page.get_element('navigator',inner_text='button') el.tap() ret = self.app.wait_util(0, 5) # 5s内, 页面没有任何未完成的异步恳求 self.assertTrue(ret, "wait success")写在最初关于Minium接口中minium、App部门的APi已经介绍完毕,那两个模块中部门Api没做分享感兴趣的同窗能够到官方文章自行查看。
认真看了下API部门还实很多,下篇文章会为各人分享Page、Element那两个模块的Api,感兴趣的同窗能够蹲一下,建议「保藏」,并「帮手转发」给你更多的人,我需要你的撑持,谢谢!
发表评论