当前位置:网站首页>关于 appium 如何关闭 app (已解决)
关于 appium 如何关闭 app (已解决)
2022-07-07 10:46:00 【全栈哈士奇】

万叶集 |
---|
隐约雷鸣,阴霾天空。 |
但盼风雨来,能留你在此。 |
前言:
作者简介:渴望力量的哈士奇 ,大家可以叫我 哈士奇 ,一位致力于 TFS - 全栈 赋能的博主
CSDN博客专家认证、新星计划第三季全栈赛道 top_1 、华为云享专家、阿里云专家博主
如果文章知识点有错误的地方,请指正!和大家一起学习,一起进步
人生格言:优于别人,并不高贵,真正的高贵应该是优于过去的自己。
如果感觉博主的文章还不错的话,还请关注、点赞、收藏三连支持一下博主哦
专栏系列(点击解锁) 学习路线指引 知识定位 Python全栈白皮书 零基础入门篇 以浅显易懂的方式轻松入门,让你彻底爱上Python的魅力。 语法进阶篇 主要围绕多线程编程、正则表达式学习、含贴近实战的项目练习 。 自动化办公篇 实现日常办公软件的自动化操作,节省时间、提高办公效率。 自动化测试实战篇 从实战的角度出发,先人一步,快速转型测试开发工程师。 数据库开发实战篇 更新中 爬虫入门与实战 更新中 数据分析篇 更新中 前端入门+flask 全栈篇 更新中 django+vue全栈篇 更新中 拓展-人工智能入门 更新中 网络安全之路 踩坑篇 记录学习及演练过程中遇到的坑,便于后来居上者 网安知识扫盲篇 三天打鱼,不深入了解原理,只会让你成为脚本小子。 vulhub靶场漏洞复现 让漏洞复现变得简单,让安全研究者更加专注于漏洞原理本身。 shell编程篇 不涉及linux基础,最终案例会偏向于安全加固方向。 [待完结] WEB漏洞攻防篇 2021年9月3日停止更新,转战先知社区等安全社区及小密圈 渗透工具使用集锦 2021年9月3日停止更新,转战先知社区等安全社区及小密圈 点点点工程师 测试神器 - Charles 软件测试数据包抓包分析神器 测试神器 - Fiddler 一文学会 fiddle ,学不会倒立吃翔,稀得! 测试神器 - Jmeter 不仅是性能测试神器,更可用于搭建轻量级接口自动化测试框架。 RobotFrameWork Python实现的自动化测试利器,该篇章仅介绍UI自动化部分。 Java实现UI自动化 文档写于2016年,Java实现的UI自动化,仍有借鉴意义。 MonkeyRunner 该工具目前的应用场景已不多,文档已删,为了排版好看才留着。

文章目录
前言
本来不想单独把这个问题抛出来单独放在一篇博文上的,知识点单一、字数贫瘠,很容易在发表之后给予质量分低下的评价。但最终还是决定将其单独放出来,因为关于 appium 如何退出 app 的操作。我也是在查找了资料咨询了几位自动化、爬虫大佬才得到了正确答案。
背景
我们都知道 appium 的底层是进行了大量的 webdriver 的封装的,所以我们在记性元素定为与 driver 的使用的时候是支持 selenium
的语法的,所以我们使用使馆的惯性下,可能进行关闭app的操作时,使用的是 driver.close(), driver.closeApp(), driver.quit()
这三种常用的关闭 driver 的方法。
但是这三种方法,都无法实现关闭 app 的操作。
分析
使用 dir函数
查看一下 driver
都有哪些方法,结果如下:
['AC_OFF', 'AC_ON', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_addCommands', '_build_data_matcher', '_file_detector', '_is_remote', '_merge_capabilities', '_mobile', '_switch_to', '_unwrap_value', '_update_command_executor', '_web_element_cls', '_wrap_value', 'activate_app', 'activate_ime_engine', 'active_ime_engine', 'add_cookie', 'all_sessions', 'app_strings', 'application_cache', 'available_ime_engines', 'back', 'background_app', 'battery_info', 'capabilities', 'close', 'close_app', 'command_executor', 'context', 'contexts', 'create_web_element', 'current_activity', 'current_context', 'current_package', 'current_url', 'current_window_handle', 'deactivate_ime_engine', 'delete_all_cookies', 'delete_cookie', 'desired_capabilities', 'device_time', 'drag_and_drop', 'end_test_coverage', 'error_handler', 'events', 'execute', 'execute_async_script', 'execute_driver', 'execute_script', 'file_detector', 'file_detector_context', 'find_element', 'find_element_by_accessibility_id', 'find_element_by_android_data_matcher', 'find_element_by_android_uiautomator', 'find_element_by_android_view_matcher', 'find_element_by_android_viewtag', 'find_element_by_class_name', 'find_element_by_css_selector', 'find_element_by_custom', 'find_element_by_id', 'find_element_by_image', 'find_element_by_ios_class_chain', 'find_element_by_ios_predicate', 'find_element_by_ios_uiautomation', 'find_element_by_link_text', 'find_element_by_name', 'find_element_by_partial_link_text', 'find_element_by_tag_name', 'find_element_by_windows_uiautomation', 'find_element_by_xpath', 'find_elements', 'find_elements_by_accessibility_id', 'find_elements_by_android_data_matcher', 'find_elements_by_android_uiautomator', 'find_elements_by_android_viewtag', 'find_elements_by_class_name', 'find_elements_by_css_selector', 'find_elements_by_custom', 'find_elements_by_id', 'find_elements_by_image', 'find_elements_by_ios_class_chain', 'find_elements_by_ios_predicate', 'find_elements_by_ios_uiautomation', 'find_elements_by_link_text', 'find_elements_by_name', 'find_elements_by_partial_link_text', 'find_elements_by_tag_name', 'find_elements_by_windows_uiautomation', 'find_elements_by_xpath', 'find_image_occurrence', 'finger_print', 'flick', 'forward', 'fullscreen_window', 'get', 'get_clipboard', 'get_clipboard_text', 'get_cookie', 'get_cookies', 'get_device_time', 'get_display_density', 'get_events', 'get_images_similarity', 'get_log', 'get_performance_data', 'get_performance_data_types', 'get_screenshot_as_base64', 'get_screenshot_as_file', 'get_screenshot_as_png', 'get_settings', 'get_system_bars', 'get_window_position', 'get_window_rect', 'get_window_size', 'hide_keyboard', 'implicitly_wait', 'install_app', 'is_app_installed', 'is_ime_active', 'is_keyboard_shown', 'is_locked', 'keyevent', 'launch_app', 'location', 'lock', 'log_event', 'log_types', 'long_press_keycode', 'make_gsm_call', 'match_images_features', 'maximize_window', 'minimize_window', 'mobile', 'name', 'network_connection', 'open_notifications', 'orientation', 'page_source', 'press_button', 'press_keycode', 'pull_file', 'pull_folder', 'push_file', 'query_app_state', 'quit', 'refresh', 'remove_app', 'reset', 'save_screenshot', 'scroll', 'send_sms', 'session', 'session_id', 'set_clipboard', 'set_clipboard_text', 'set_gsm_signal', 'set_gsm_voice', 'set_location', 'set_network_connection', 'set_network_speed', 'set_page_load_timeout', 'set_power_ac', 'set_power_capacity', 'set_script_timeout', 'set_value', 'set_window_position', 'set_window_rect', 'set_window_size', 'shake', 'start_activity', 'start_client', 'start_recording_screen', 'start_session', 'stop_client', 'stop_recording_screen', 'swipe', 'switch_to', 'switch_to_active_element', 'switch_to_alert', 'switch_to_default_content', 'switch_to_frame', 'switch_to_window', 'tap', 'terminate_app', 'title', 'toggle_location_services', 'toggle_touch_id_enrollment', 'toggle_wifi', 'touch_id', 'unlock', 'update_settings', 'w3c', 'wait_activity', 'window_handles']
解决关闭 app 的方法
在以上的 dir() 函数查找到的结果,存在着一个 terminate_app
方法,该方法需要一个 app_id
参数,其实就是 app 的包名,比如 百度APP
的包名就是 com.baidu.searchbox
,尝试利用该方法,关闭 app ,完美解决。

边栏推荐
- Query whether a field has an index with MySQL
- ip2long与long2IP 分析
- Utiliser la pile pour convertir le binaire en décimal
- SSM框架搭建的步骤
- leetcode刷题:二叉树26(二叉搜索树中的插入操作)
- 爱可可AI前沿推介(7.7)
- 2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
- 如何将 @Transactional 事务注解运用到炉火纯青?
- Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
- 在字符串中查找id值MySQL
猜你喜欢
Decrypt gd32 MCU product family, how to choose the development board?
JS to convert array to tree data
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
How to use PS link layer and shortcut keys, and how to do PS layer link
[statistical learning methods] learning notes - improvement methods
Day-15 common APIs and exception mechanisms
Day-19 IO stream
[爬虫]使用selenium时,躲避脚本检测
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
数据库安全的重要性
随机推荐
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
[pytorch practice] image description -- let neural network read pictures and tell stories
Day-19 IO stream
On valuation model (II): PE index II - PE band
BGP third experiment report
How to apply @transactional transaction annotation to perfection?
Several ways to clear floating
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
怎样重置火狐浏览器
test
Realize all, race, allsettled and any of the simple version of promise by yourself
Four functions of opencv
详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
Day21 multithreading
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
Query whether a field has an index with MySQL
Common knowledge of one-dimensional array and two-dimensional array
Leetcode skimming: binary tree 21 (verifying binary search tree)
[statistical learning methods] learning notes - improvement methods
《ASP.NET Core 6框架揭秘》样章[200页/5章]