Appium-Python-Client 5.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- appium/__init__.py +17 -0
- appium/common/__init__.py +17 -0
- appium/common/exceptions.py +26 -0
- appium/common/helper.py +42 -0
- appium/common/logger.py +28 -0
- appium/options/__init__.py +0 -0
- appium/options/android/__init__.py +2 -0
- appium/options/android/common/__init__.py +0 -0
- appium/options/android/common/adb/__init__.py +0 -0
- appium/options/android/common/adb/adb_exec_timeout_option.py +41 -0
- appium/options/android/common/adb/adb_port_option.py +38 -0
- appium/options/android/common/adb/allow_delay_adb_option.py +39 -0
- appium/options/android/common/adb/build_tools_version_option.py +42 -0
- appium/options/android/common/adb/clear_device_logs_on_start_option.py +40 -0
- appium/options/android/common/adb/ignore_hidden_api_policy_error_option.py +40 -0
- appium/options/android/common/adb/logcat_filter_specs_option.py +42 -0
- appium/options/android/common/adb/logcat_format_option.py +39 -0
- appium/options/android/common/adb/mock_location_app_option.py +42 -0
- appium/options/android/common/adb/remote_adb_host_option.py +39 -0
- appium/options/android/common/adb/skip_logcat_capture_option.py +40 -0
- appium/options/android/common/adb/suppress_kill_server_option.py +39 -0
- appium/options/android/common/app/__init__.py +0 -0
- appium/options/android/common/app/allow_test_packages_option.py +40 -0
- appium/options/android/common/app/android_install_timeout_option.py +43 -0
- appium/options/android/common/app/app_activity_option.py +39 -0
- appium/options/android/common/app/app_package_option.py +39 -0
- appium/options/android/common/app/app_wait_activity_option.py +40 -0
- appium/options/android/common/app/app_wait_duration_option.py +41 -0
- appium/options/android/common/app/app_wait_for_launch_option.py +41 -0
- appium/options/android/common/app/app_wait_package_option.py +40 -0
- appium/options/android/common/app/auto_grant_premissions_option.py +40 -0
- appium/options/android/common/app/enforce_app_install_option.py +40 -0
- appium/options/android/common/app/intent_action_option.py +40 -0
- appium/options/android/common/app/intent_category_option.py +40 -0
- appium/options/android/common/app/intent_flags_option.py +40 -0
- appium/options/android/common/app/optional_intent_arguments_option.py +40 -0
- appium/options/android/common/app/remote_apps_cache_limit_option.py +42 -0
- appium/options/android/common/app/uninstall_other_packages_option.py +39 -0
- appium/options/android/common/avd/__init__.py +0 -0
- appium/options/android/common/avd/avd_args_option.py +38 -0
- appium/options/android/common/avd/avd_env_option.py +38 -0
- appium/options/android/common/avd/avd_launch_timeout_option.py +41 -0
- appium/options/android/common/avd/avd_option.py +41 -0
- appium/options/android/common/avd/avd_ready_timeout_option.py +41 -0
- appium/options/android/common/avd/gps_enabled_option.py +39 -0
- appium/options/android/common/avd/network_speed_option.py +41 -0
- appium/options/android/common/context/__init__.py +0 -0
- appium/options/android/common/context/auto_webview_timeout_option.py +41 -0
- appium/options/android/common/context/chrome_logging_prefs_option.py +41 -0
- appium/options/android/common/context/chrome_options_option.py +40 -0
- appium/options/android/common/context/chromedriver_args_option.py +41 -0
- appium/options/android/common/context/chromedriver_chrome_mapping_file_option.py +43 -0
- appium/options/android/common/context/chromedriver_disable_build_check_option.py +41 -0
- appium/options/android/common/context/chromedriver_executable_dir_option.py +43 -0
- appium/options/android/common/context/chromedriver_executable_option.py +38 -0
- appium/options/android/common/context/chromedriver_port_option.py +39 -0
- appium/options/android/common/context/chromedriver_ports_option.py +39 -0
- appium/options/android/common/context/chromedriver_use_system_executable_option.py +40 -0
- appium/options/android/common/context/ensure_webviews_have_pages_option.py +40 -0
- appium/options/android/common/context/extract_chrome_android_package_from_context_name_option.py +40 -0
- appium/options/android/common/context/native_web_screenshot_option.py +40 -0
- appium/options/android/common/context/recreate_chrome_driver_sessions_option.py +41 -0
- appium/options/android/common/context/show_chromedriver_log_option.py +39 -0
- appium/options/android/common/context/webview_devtools_port_option.py +40 -0
- appium/options/android/common/localization/__init__.py +0 -0
- appium/options/android/common/localization/locale_script_option.py +40 -0
- appium/options/android/common/locking/__init__.py +0 -0
- appium/options/android/common/locking/skip_unlock_option.py +42 -0
- appium/options/android/common/locking/unlock_key_option.py +40 -0
- appium/options/android/common/locking/unlock_strategy_option.py +40 -0
- appium/options/android/common/locking/unlock_success_timeout_option.py +43 -0
- appium/options/android/common/locking/unlock_type_option.py +40 -0
- appium/options/android/common/mjpeg/__init__.py +0 -0
- appium/options/android/common/mjpeg/mjpeg_screenshot_url_option.py +40 -0
- appium/options/android/common/other/__init__.py +0 -0
- appium/options/android/common/other/disable_suppress_accessibility_service_option.py +40 -0
- appium/options/android/common/other/user_profile_option.py +42 -0
- appium/options/android/common/signing/__init__.py +0 -0
- appium/options/android/common/signing/key_alias_option.py +40 -0
- appium/options/android/common/signing/key_password_option.py +40 -0
- appium/options/android/common/signing/keystore_password_option.py +40 -0
- appium/options/android/common/signing/keystore_path_option.py +40 -0
- appium/options/android/common/signing/no_sign_option.py +42 -0
- appium/options/android/common/signing/use_keystore_option.py +42 -0
- appium/options/android/espresso/__init__.py +0 -0
- appium/options/android/espresso/activity_options_option.py +41 -0
- appium/options/android/espresso/app_locale_option.py +44 -0
- appium/options/android/espresso/base.py +221 -0
- appium/options/android/espresso/espresso_build_config_option.py +46 -0
- appium/options/android/espresso/espresso_server_launch_timeout_option.py +43 -0
- appium/options/android/espresso/force_espresso_rebuild_option.py +41 -0
- appium/options/android/espresso/intent_options_option.py +41 -0
- appium/options/android/espresso/show_gradle_log_option.py +39 -0
- appium/options/android/uiautomator2/__init__.py +0 -0
- appium/options/android/uiautomator2/base.py +221 -0
- appium/options/android/uiautomator2/disable_window_animation_option.py +40 -0
- appium/options/android/uiautomator2/mjpeg_server_port_option.py +41 -0
- appium/options/android/uiautomator2/skip_device_initialization_option.py +40 -0
- appium/options/android/uiautomator2/skip_server_installation_option.py +44 -0
- appium/options/android/uiautomator2/uiautomator2_server_install_timeout_option.py +44 -0
- appium/options/android/uiautomator2/uiautomator2_server_launch_timeout_option.py +44 -0
- appium/options/android/uiautomator2/uiautomator2_server_read_timeout_option.py +46 -0
- appium/options/common/__init__.py +1 -0
- appium/options/common/app_option.py +41 -0
- appium/options/common/auto_web_view_option.py +40 -0
- appium/options/common/automation_name_option.py +38 -0
- appium/options/common/base.py +125 -0
- appium/options/common/browser_name_option.py +38 -0
- appium/options/common/bundle_id_option.py +38 -0
- appium/options/common/clear_system_files_option.py +38 -0
- appium/options/common/device_name_option.py +38 -0
- appium/options/common/enable_performance_logging_option.py +38 -0
- appium/options/common/event_timings_option.py +40 -0
- appium/options/common/full_reset_option.py +38 -0
- appium/options/common/is_headless_option.py +39 -0
- appium/options/common/language_option.py +38 -0
- appium/options/common/locale_option.py +38 -0
- appium/options/common/new_command_timeout_option.py +41 -0
- appium/options/common/no_reset_option.py +38 -0
- appium/options/common/orientation_option.py +40 -0
- appium/options/common/other_apps_option.py +39 -0
- appium/options/common/platform_version_option.py +40 -0
- appium/options/common/postrun_option.py +39 -0
- appium/options/common/prerun_option.py +40 -0
- appium/options/common/print_page_source_on_find_failure_option.py +40 -0
- appium/options/common/skip_log_capture_option.py +38 -0
- appium/options/common/supports_capabilities.py +26 -0
- appium/options/common/system_host_option.py +38 -0
- appium/options/common/system_port_option.py +38 -0
- appium/options/common/udid_option.py +38 -0
- appium/options/flutter_integration/__init__.py +15 -0
- appium/options/flutter_integration/base.py +39 -0
- appium/options/flutter_integration/flutter_element_wait_timeout_option.py +50 -0
- appium/options/flutter_integration/flutter_enable_mock_camera_option.py +44 -0
- appium/options/flutter_integration/flutter_server_launch_timeout_option.py +51 -0
- appium/options/flutter_integration/flutter_system_port_option.py +45 -0
- appium/options/gecko/__init__.py +1 -0
- appium/options/gecko/android_storage_option.py +39 -0
- appium/options/gecko/base.py +51 -0
- appium/options/gecko/firefox_options_option.py +38 -0
- appium/options/gecko/marionette_port_option.py +43 -0
- appium/options/gecko/verbosity_option.py +40 -0
- appium/options/ios/__init__.py +2 -0
- appium/options/ios/safari/__init__.py +0 -0
- appium/options/ios/safari/automatic_inspection_option.py +41 -0
- appium/options/ios/safari/automatic_profiling_option.py +41 -0
- appium/options/ios/safari/base.py +51 -0
- appium/options/ios/safari/device_name_option.py +43 -0
- appium/options/ios/safari/device_type_option.py +41 -0
- appium/options/ios/safari/device_udid_option.py +43 -0
- appium/options/ios/safari/platform_build_version_option.py +41 -0
- appium/options/ios/safari/platform_version_option.py +41 -0
- appium/options/ios/safari/use_simulator_option.py +41 -0
- appium/options/ios/safari/webkit_webrtc_option.py +52 -0
- appium/options/ios/xcuitest/__init__.py +0 -0
- appium/options/ios/xcuitest/app/__init__.py +0 -0
- appium/options/ios/xcuitest/app/app_install_strategy_option.py +46 -0
- appium/options/ios/xcuitest/app/app_push_timeout_option.py +42 -0
- appium/options/ios/xcuitest/app/localizable_strings_dir_option.py +39 -0
- appium/options/ios/xcuitest/base.py +223 -0
- appium/options/ios/xcuitest/general/__init__.py +0 -0
- appium/options/ios/xcuitest/general/include_device_caps_to_session_info_option.py +41 -0
- appium/options/ios/xcuitest/general/reset_location_service_option.py +39 -0
- appium/options/ios/xcuitest/other/__init__.py +0 -0
- appium/options/ios/xcuitest/other/command_timeouts_option.py +57 -0
- appium/options/ios/xcuitest/other/launch_with_idb_option.py +42 -0
- appium/options/ios/xcuitest/other/show_ios_log_option.py +39 -0
- appium/options/ios/xcuitest/other/use_json_source_option.py +39 -0
- appium/options/ios/xcuitest/simulator/__init__.py +0 -0
- appium/options/ios/xcuitest/simulator/calendar_access_authorized_option.py +41 -0
- appium/options/ios/xcuitest/simulator/calendar_format_option.py +38 -0
- appium/options/ios/xcuitest/simulator/connect_hardware_keyboard_option.py +43 -0
- appium/options/ios/xcuitest/simulator/custom_ssl_cert_option.py +39 -0
- appium/options/ios/xcuitest/simulator/enforce_fresh_simulator_creation_option.py +39 -0
- appium/options/ios/xcuitest/simulator/force_simulator_software_keyboard_presence_option.py +45 -0
- appium/options/ios/xcuitest/simulator/ios_simulator_logs_predicate_option.py +38 -0
- appium/options/ios/xcuitest/simulator/keep_key_chains_option.py +39 -0
- appium/options/ios/xcuitest/simulator/keychains_exclude_patterns_option.py +44 -0
- appium/options/ios/xcuitest/simulator/permissions_option.py +50 -0
- appium/options/ios/xcuitest/simulator/reduce_motion_option.py +40 -0
- appium/options/ios/xcuitest/simulator/reset_on_session_start_only_option.py +41 -0
- appium/options/ios/xcuitest/simulator/scale_factor_option.py +44 -0
- appium/options/ios/xcuitest/simulator/shutdown_other_simulators_option.py +44 -0
- appium/options/ios/xcuitest/simulator/simulator_devices_set_path_option.py +41 -0
- appium/options/ios/xcuitest/simulator/simulator_pasteboard_automatic_sync_option.py +42 -0
- appium/options/ios/xcuitest/simulator/simulator_startup_timeout_option.py +46 -0
- appium/options/ios/xcuitest/simulator/simulator_trace_pointer_option.py +41 -0
- appium/options/ios/xcuitest/simulator/simulator_window_center_option.py +41 -0
- appium/options/ios/xcuitest/wda/__init__.py +0 -0
- appium/options/ios/xcuitest/wda/allow_provisioning_device_regitration_option.py +40 -0
- appium/options/ios/xcuitest/wda/auto_accept_alerts_option.py +39 -0
- appium/options/ios/xcuitest/wda/auto_disimiss_alerts_option.py +39 -0
- appium/options/ios/xcuitest/wda/derived_data_path_option.py +41 -0
- appium/options/ios/xcuitest/wda/disable_automatic_screenshots_option.py +40 -0
- appium/options/ios/xcuitest/wda/force_app_launch_option.py +42 -0
- appium/options/ios/xcuitest/wda/keychain_password_option.py +39 -0
- appium/options/ios/xcuitest/wda/keychain_path_option.py +39 -0
- appium/options/ios/xcuitest/wda/max_typing_frequency_option.py +40 -0
- appium/options/ios/xcuitest/wda/mjpeg_server_port_option.py +42 -0
- appium/options/ios/xcuitest/wda/process_arguments_option.py +42 -0
- appium/options/ios/xcuitest/wda/result_bundle_path_option.py +42 -0
- appium/options/ios/xcuitest/wda/screenshot_quality_option.py +42 -0
- appium/options/ios/xcuitest/wda/should_terminate_app_option.py +42 -0
- appium/options/ios/xcuitest/wda/should_use_singleton_test_manager_option.py +39 -0
- appium/options/ios/xcuitest/wda/show_xcode_log_option.py +40 -0
- appium/options/ios/xcuitest/wda/simple_is_visible_check_option.py +42 -0
- appium/options/ios/xcuitest/wda/updated_wda_bundle_id_option.py +39 -0
- appium/options/ios/xcuitest/wda/use_native_caching_strategy_option.py +41 -0
- appium/options/ios/xcuitest/wda/use_new_wda_option.py +51 -0
- appium/options/ios/xcuitest/wda/use_prebuilt_wda_option.py +39 -0
- appium/options/ios/xcuitest/wda/use_simple_build_test_option.py +40 -0
- appium/options/ios/xcuitest/wda/use_xctestrun_file_option.py +49 -0
- appium/options/ios/xcuitest/wda/wait_for_idle_timeout_option.py +45 -0
- appium/options/ios/xcuitest/wda/wait_for_quiescence_option.py +42 -0
- appium/options/ios/xcuitest/wda/wda_base_url_option.py +41 -0
- appium/options/ios/xcuitest/wda/wda_connection_timeout_option.py +43 -0
- appium/options/ios/xcuitest/wda/wda_eventloop_idle_delay_option.py +46 -0
- appium/options/ios/xcuitest/wda/wda_launch_timeout_option.py +41 -0
- appium/options/ios/xcuitest/wda/wda_local_port_option.py +41 -0
- appium/options/ios/xcuitest/wda/wda_startup_retries_option.py +39 -0
- appium/options/ios/xcuitest/wda/wda_startup_retry_interval_option.py +43 -0
- appium/options/ios/xcuitest/wda/web_driver_agent_url_option.py +39 -0
- appium/options/ios/xcuitest/wda/xcode_org_id_option.py +39 -0
- appium/options/ios/xcuitest/wda/xcode_signing_id_option.py +39 -0
- appium/options/ios/xcuitest/webview/__init__.py +0 -0
- appium/options/ios/xcuitest/webview/absolute_web_locations_option.py +42 -0
- appium/options/ios/xcuitest/webview/additional_webview_bundle_ids_option.py +40 -0
- appium/options/ios/xcuitest/webview/enable_async_execute_from_https_option.py +39 -0
- appium/options/ios/xcuitest/webview/full_context_list_option.py +42 -0
- appium/options/ios/xcuitest/webview/include_safari_in_webviews_option.py +41 -0
- appium/options/ios/xcuitest/webview/native_web_tap_option.py +40 -0
- appium/options/ios/xcuitest/webview/safari_garbage_collect_option.py +39 -0
- appium/options/ios/xcuitest/webview/safari_ignore_fraud_warning_option.py +39 -0
- appium/options/ios/xcuitest/webview/safari_ignore_web_hostnames_option.py +42 -0
- appium/options/ios/xcuitest/webview/safari_initial_url_option.py +38 -0
- appium/options/ios/xcuitest/webview/safari_log_all_communication_hex_dump_option.py +43 -0
- appium/options/ios/xcuitest/webview/safari_log_all_communication_option.py +40 -0
- appium/options/ios/xcuitest/webview/safari_open_links_in_background_option.py +39 -0
- appium/options/ios/xcuitest/webview/safari_socket_chunk_size_option.py +41 -0
- appium/options/ios/xcuitest/webview/safari_web_inspector_max_frame_length_option.py +41 -0
- appium/options/ios/xcuitest/webview/webkit_response_timeout_option.py +43 -0
- appium/options/ios/xcuitest/webview/webview_connect_retries_option.py +40 -0
- appium/options/ios/xcuitest/webview/webview_connect_timeout_option.py +43 -0
- appium/options/mac/__init__.py +1 -0
- appium/options/mac/mac2/__init__.py +0 -0
- appium/options/mac/mac2/app_path_option.py +39 -0
- appium/options/mac/mac2/arguments_option.py +39 -0
- appium/options/mac/mac2/base.py +113 -0
- appium/options/mac/mac2/bootstrap_root_option.py +41 -0
- appium/options/mac/mac2/environment_option.py +41 -0
- appium/options/mac/mac2/server_startup_timeout_option.py +44 -0
- appium/options/mac/mac2/show_server_logs_option.py +39 -0
- appium/options/mac/mac2/skip_app_kill_option.py +40 -0
- appium/options/mac/mac2/web_driver_agent_mac_url_option.py +39 -0
- appium/options/windows/__init__.py +1 -0
- appium/options/windows/windows/__init__.py +0 -0
- appium/options/windows/windows/app_arguments_option.py +40 -0
- appium/options/windows/windows/app_top_level_window_option.py +40 -0
- appium/options/windows/windows/app_working_dir_option.py +40 -0
- appium/options/windows/windows/base.py +97 -0
- appium/options/windows/windows/create_session_timeout_option.py +45 -0
- appium/options/windows/windows/expreimental_web_driver_option.py +39 -0
- appium/options/windows/windows/wait_for_app_launch_option.py +43 -0
- appium/protocols/__init__.py +13 -0
- appium/protocols/webdriver/__init__.py +13 -0
- appium/protocols/webdriver/can_execute_commands.py +23 -0
- appium/protocols/webdriver/can_execute_scripts.py +27 -0
- appium/protocols/webdriver/can_find_elements.py +32 -0
- appium/protocols/webdriver/can_remember_extension_presence.py +23 -0
- appium/py.typed +0 -0
- appium/version.py +22 -0
- appium/webdriver/__init__.py +20 -0
- appium/webdriver/appium_connection.py +65 -0
- appium/webdriver/appium_service.py +330 -0
- appium/webdriver/applicationstate.py +21 -0
- appium/webdriver/client_config.py +38 -0
- appium/webdriver/clipboard_content_type.py +19 -0
- appium/webdriver/command_method.py +27 -0
- appium/webdriver/common/__init__.py +17 -0
- appium/webdriver/common/appiumby.py +54 -0
- appium/webdriver/connectiontype.py +42 -0
- appium/webdriver/errorhandler.py +125 -0
- appium/webdriver/extensions/__init__.py +13 -0
- appium/webdriver/extensions/action_helpers.py +188 -0
- appium/webdriver/extensions/android/__init__.py +0 -0
- appium/webdriver/extensions/android/activities.py +65 -0
- appium/webdriver/extensions/android/common.py +59 -0
- appium/webdriver/extensions/android/display.py +48 -0
- appium/webdriver/extensions/android/gsm.py +147 -0
- appium/webdriver/extensions/android/nativekey.py +1119 -0
- appium/webdriver/extensions/android/network.py +175 -0
- appium/webdriver/extensions/android/performance.py +85 -0
- appium/webdriver/extensions/android/power.py +80 -0
- appium/webdriver/extensions/android/sms.py +50 -0
- appium/webdriver/extensions/android/system_bars.py +58 -0
- appium/webdriver/extensions/applications.py +274 -0
- appium/webdriver/extensions/clipboard.py +107 -0
- appium/webdriver/extensions/context.py +63 -0
- appium/webdriver/extensions/device_time.py +75 -0
- appium/webdriver/extensions/execute_driver.py +60 -0
- appium/webdriver/extensions/execute_mobile_command.py +62 -0
- appium/webdriver/extensions/flutter_integration/__init__.py +13 -0
- appium/webdriver/extensions/flutter_integration/flutter_commands.py +296 -0
- appium/webdriver/extensions/flutter_integration/flutter_finder.py +55 -0
- appium/webdriver/extensions/flutter_integration/scroll_directions.py +6 -0
- appium/webdriver/extensions/hw_actions.py +149 -0
- appium/webdriver/extensions/images_comparison.py +132 -0
- appium/webdriver/extensions/keyboard.py +168 -0
- appium/webdriver/extensions/location.py +98 -0
- appium/webdriver/extensions/log_event.py +68 -0
- appium/webdriver/extensions/logs.py +53 -0
- appium/webdriver/extensions/remote_fs.py +110 -0
- appium/webdriver/extensions/screen_record.py +207 -0
- appium/webdriver/extensions/session.py +41 -0
- appium/webdriver/extensions/settings.py +49 -0
- appium/webdriver/locator_converter.py +29 -0
- appium/webdriver/mobilecommand.py +104 -0
- appium/webdriver/switch_to.py +35 -0
- appium/webdriver/webdriver.py +495 -0
- appium/webdriver/webelement.py +130 -0
- appium_python_client-5.2.0.dist-info/METADATA +573 -0
- appium_python_client-5.2.0.dist-info/RECORD +324 -0
- appium_python_client-5.2.0.dist-info/WHEEL +4 -0
- appium_python_client-5.2.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from typing import Any, Dict, Union
|
|
15
|
+
|
|
16
|
+
from selenium.common.exceptions import InvalidArgumentException, UnknownMethodException
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
|
|
19
|
+
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
20
|
+
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
21
|
+
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
22
|
+
|
|
23
|
+
from ..mobilecommand import MobileCommand as Command
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Applications(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
27
|
+
def background_app(self, seconds: int) -> Self:
|
|
28
|
+
"""Puts the application in the background on the device for a certain duration.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
seconds: the duration for the application to remain in the background.
|
|
32
|
+
Providing a negative value will continue immediately after putting the app
|
|
33
|
+
under test to the background.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Union['WebDriver', 'Applications']: Self instance
|
|
37
|
+
"""
|
|
38
|
+
ext_name = 'mobile: backgroundApp'
|
|
39
|
+
args = {'seconds': seconds}
|
|
40
|
+
try:
|
|
41
|
+
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
42
|
+
except UnknownMethodException:
|
|
43
|
+
# TODO: Remove the fallback
|
|
44
|
+
self.mark_extension_absence(ext_name).execute(Command.BACKGROUND, args)
|
|
45
|
+
return self
|
|
46
|
+
|
|
47
|
+
def is_app_installed(self, bundle_id: str) -> bool:
|
|
48
|
+
"""Checks whether the application specified by `bundle_id` is installed on the device.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
bundle_id: the id of the application to query
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
`True` if app is installed
|
|
55
|
+
"""
|
|
56
|
+
ext_name = 'mobile: isAppInstalled'
|
|
57
|
+
try:
|
|
58
|
+
return self.assert_extension_exists(ext_name).execute_script(
|
|
59
|
+
ext_name,
|
|
60
|
+
{
|
|
61
|
+
'bundleId': bundle_id,
|
|
62
|
+
'appId': bundle_id,
|
|
63
|
+
},
|
|
64
|
+
)
|
|
65
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
66
|
+
# TODO: Remove the fallback
|
|
67
|
+
return self.mark_extension_absence(ext_name).execute(
|
|
68
|
+
Command.IS_APP_INSTALLED,
|
|
69
|
+
{
|
|
70
|
+
'bundleId': bundle_id,
|
|
71
|
+
},
|
|
72
|
+
)['value']
|
|
73
|
+
|
|
74
|
+
def install_app(self, app_path: str, **options: Any) -> Self:
|
|
75
|
+
"""Install the application found at `app_path` on the device.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
app_path: the local or remote path to the application to install
|
|
79
|
+
|
|
80
|
+
Keyword Args:
|
|
81
|
+
replace (bool): [Android only] whether to reinstall/upgrade the package if it is
|
|
82
|
+
already present on the device under test. True by default
|
|
83
|
+
timeout (int): [Android only] how much time to wait for the installation to complete.
|
|
84
|
+
60000ms by default.
|
|
85
|
+
allowTestPackages (bool): [Android only] whether to allow installation of packages marked
|
|
86
|
+
as test in the manifest. False by default
|
|
87
|
+
useSdcard (bool): [Android only] whether to use the SD card to install the app. False by default
|
|
88
|
+
grantPermissions (bool): [Android only] whether to automatically grant application permissions
|
|
89
|
+
on Android 6+ after the installation completes. False by default
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Union['WebDriver', 'Applications']: Self instance
|
|
93
|
+
"""
|
|
94
|
+
ext_name = 'mobile: installApp'
|
|
95
|
+
try:
|
|
96
|
+
self.assert_extension_exists(ext_name).execute_script(
|
|
97
|
+
'mobile: installApp',
|
|
98
|
+
{
|
|
99
|
+
'app': app_path,
|
|
100
|
+
'appPath': app_path,
|
|
101
|
+
**(options or {}),
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
105
|
+
# TODO: Remove the fallback
|
|
106
|
+
data: Dict[str, Any] = {'appPath': app_path}
|
|
107
|
+
if options:
|
|
108
|
+
data.update({'options': options})
|
|
109
|
+
self.mark_extension_absence(ext_name).execute(Command.INSTALL_APP, data)
|
|
110
|
+
return self
|
|
111
|
+
|
|
112
|
+
def remove_app(self, app_id: str, **options: Any) -> Self:
|
|
113
|
+
"""Remove the specified application from the device.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
app_id: the application id to be removed
|
|
117
|
+
|
|
118
|
+
Keyword Args:
|
|
119
|
+
keepData (bool): [Android only] whether to keep application data and caches after it is uninstalled.
|
|
120
|
+
False by default
|
|
121
|
+
timeout (int): [Android only] how much time to wait for the uninstall to complete.
|
|
122
|
+
20000ms by default.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Union['WebDriver', 'Applications']: Self instance
|
|
126
|
+
"""
|
|
127
|
+
ext_name = 'mobile: removeApp'
|
|
128
|
+
try:
|
|
129
|
+
self.assert_extension_exists(ext_name).execute_script(
|
|
130
|
+
ext_name,
|
|
131
|
+
{
|
|
132
|
+
'appId': app_id,
|
|
133
|
+
'bundleId': app_id,
|
|
134
|
+
**(options or {}),
|
|
135
|
+
},
|
|
136
|
+
)
|
|
137
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
138
|
+
# TODO: Remove the fallback
|
|
139
|
+
data: Dict[str, Any] = {'appId': app_id}
|
|
140
|
+
if options:
|
|
141
|
+
data.update({'options': options})
|
|
142
|
+
self.mark_extension_absence(ext_name).execute(Command.REMOVE_APP, data)
|
|
143
|
+
return self
|
|
144
|
+
|
|
145
|
+
def terminate_app(self, app_id: str, **options: Any) -> bool:
|
|
146
|
+
"""Terminates the application if it is running.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
app_id: the application id to be terminates
|
|
150
|
+
|
|
151
|
+
Keyword Args:
|
|
152
|
+
`timeout` (int): [Android only] how much time to wait for the uninstall to complete.
|
|
153
|
+
500ms by default.
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
True if the app has been successfully terminated
|
|
157
|
+
"""
|
|
158
|
+
ext_name = 'mobile: terminateApp'
|
|
159
|
+
try:
|
|
160
|
+
return self.assert_extension_exists(ext_name).execute_script(
|
|
161
|
+
ext_name,
|
|
162
|
+
{
|
|
163
|
+
'appId': app_id,
|
|
164
|
+
'bundleId': app_id,
|
|
165
|
+
**(options or {}),
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
169
|
+
# TODO: Remove the fallback
|
|
170
|
+
data: Dict[str, Any] = {'appId': app_id}
|
|
171
|
+
if options:
|
|
172
|
+
data.update({'options': options})
|
|
173
|
+
return self.mark_extension_absence(ext_name).execute(Command.TERMINATE_APP, data)['value']
|
|
174
|
+
|
|
175
|
+
def activate_app(self, app_id: str) -> Self:
|
|
176
|
+
"""Activates the application if it is not running
|
|
177
|
+
or is running in the background.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
app_id: the application id to be activated
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Union['WebDriver', 'Applications']: Self instance
|
|
184
|
+
"""
|
|
185
|
+
ext_name = 'mobile: activateApp'
|
|
186
|
+
try:
|
|
187
|
+
self.assert_extension_exists(ext_name).execute_script(
|
|
188
|
+
ext_name,
|
|
189
|
+
{
|
|
190
|
+
'appId': app_id,
|
|
191
|
+
'bundleId': app_id,
|
|
192
|
+
},
|
|
193
|
+
)
|
|
194
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
195
|
+
# TODO: Remove the fallback
|
|
196
|
+
self.mark_extension_absence(ext_name).execute(Command.ACTIVATE_APP, {'appId': app_id})
|
|
197
|
+
return self
|
|
198
|
+
|
|
199
|
+
def query_app_state(self, app_id: str) -> int:
|
|
200
|
+
"""Queries the state of the application.
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
app_id: the application id to be queried
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
One of possible application state constants. See ApplicationState
|
|
207
|
+
class for more details.
|
|
208
|
+
"""
|
|
209
|
+
ext_name = 'mobile: queryAppState'
|
|
210
|
+
try:
|
|
211
|
+
return self.assert_extension_exists(ext_name).execute_script(
|
|
212
|
+
ext_name,
|
|
213
|
+
{
|
|
214
|
+
'appId': app_id,
|
|
215
|
+
'bundleId': app_id,
|
|
216
|
+
},
|
|
217
|
+
)
|
|
218
|
+
except (UnknownMethodException, InvalidArgumentException):
|
|
219
|
+
# TODO: Remove the fallback
|
|
220
|
+
return self.mark_extension_absence(ext_name).execute(
|
|
221
|
+
Command.QUERY_APP_STATE,
|
|
222
|
+
{
|
|
223
|
+
'appId': app_id,
|
|
224
|
+
},
|
|
225
|
+
)['value']
|
|
226
|
+
|
|
227
|
+
def app_strings(self, language: Union[str, None] = None, string_file: Union[str, None] = None) -> Dict[str, str]:
|
|
228
|
+
"""Returns the application strings from the device for the specified
|
|
229
|
+
language.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
language: strings language code
|
|
233
|
+
string_file: the name of the string file to query. Only relevant for XCUITest driver
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
The key is string id and the value is the content.
|
|
237
|
+
"""
|
|
238
|
+
ext_name = 'mobile: getAppStrings'
|
|
239
|
+
data = {}
|
|
240
|
+
if language is not None:
|
|
241
|
+
data['language'] = language
|
|
242
|
+
if string_file is not None:
|
|
243
|
+
data['stringFile'] = string_file
|
|
244
|
+
try:
|
|
245
|
+
return self.assert_extension_exists(ext_name).execute_script(ext_name, data)
|
|
246
|
+
except UnknownMethodException:
|
|
247
|
+
# TODO: Remove the fallback
|
|
248
|
+
return self.mark_extension_absence(ext_name).execute(Command.GET_APP_STRINGS, data)['value']
|
|
249
|
+
|
|
250
|
+
def _add_commands(self) -> None:
|
|
251
|
+
self.command_executor.add_command(Command.BACKGROUND, 'POST', '/session/$sessionId/appium/app/background')
|
|
252
|
+
self.command_executor.add_command(
|
|
253
|
+
Command.IS_APP_INSTALLED,
|
|
254
|
+
'POST',
|
|
255
|
+
'/session/$sessionId/appium/device/app_installed',
|
|
256
|
+
)
|
|
257
|
+
self.command_executor.add_command(Command.INSTALL_APP, 'POST', '/session/$sessionId/appium/device/install_app')
|
|
258
|
+
self.command_executor.add_command(Command.REMOVE_APP, 'POST', '/session/$sessionId/appium/device/remove_app')
|
|
259
|
+
self.command_executor.add_command(
|
|
260
|
+
Command.TERMINATE_APP,
|
|
261
|
+
'POST',
|
|
262
|
+
'/session/$sessionId/appium/device/terminate_app',
|
|
263
|
+
)
|
|
264
|
+
self.command_executor.add_command(
|
|
265
|
+
Command.ACTIVATE_APP,
|
|
266
|
+
'POST',
|
|
267
|
+
'/session/$sessionId/appium/device/activate_app',
|
|
268
|
+
)
|
|
269
|
+
self.command_executor.add_command(
|
|
270
|
+
Command.QUERY_APP_STATE,
|
|
271
|
+
'POST',
|
|
272
|
+
'/session/$sessionId/appium/device/app_state',
|
|
273
|
+
)
|
|
274
|
+
self.command_executor.add_command(Command.GET_APP_STRINGS, 'POST', '/session/$sessionId/appium/app/strings')
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import base64
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
from selenium.common.exceptions import UnknownMethodException
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
22
|
+
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
23
|
+
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
24
|
+
from appium.webdriver.clipboard_content_type import ClipboardContentType
|
|
25
|
+
|
|
26
|
+
from ..mobilecommand import MobileCommand as Command
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Clipboard(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
30
|
+
def set_clipboard(
|
|
31
|
+
self, content: bytes, content_type: str = ClipboardContentType.PLAINTEXT, label: Optional[str] = None
|
|
32
|
+
) -> Self:
|
|
33
|
+
"""Set the content of the system clipboard
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
content: The content to be set as bytearray string
|
|
37
|
+
content_type: One of ClipboardContentType items. Only ClipboardContentType.PLAINTEXT
|
|
38
|
+
is supported on Android
|
|
39
|
+
label: label argument, which only works for Android
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
Union['WebDriver', 'Clipboard']: Self instance
|
|
43
|
+
"""
|
|
44
|
+
ext_name = 'mobile: setClipboard'
|
|
45
|
+
options = {
|
|
46
|
+
'content': base64.b64encode(content).decode('UTF-8'),
|
|
47
|
+
'contentType': content_type,
|
|
48
|
+
}
|
|
49
|
+
if label:
|
|
50
|
+
options['label'] = label
|
|
51
|
+
try:
|
|
52
|
+
self.assert_extension_exists(ext_name).execute_script(ext_name, options)
|
|
53
|
+
except UnknownMethodException:
|
|
54
|
+
# TODO: Remove the fallback
|
|
55
|
+
self.mark_extension_absence(ext_name).execute(Command.SET_CLIPBOARD, options)
|
|
56
|
+
return self
|
|
57
|
+
|
|
58
|
+
def set_clipboard_text(self, text: str, label: Optional[str] = None) -> Self:
|
|
59
|
+
"""Copies the given text to the system clipboard
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
text: The text to be set
|
|
63
|
+
label:label argument, which only works for Android
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
Union['WebDriver', 'Clipboard']: Self instance
|
|
67
|
+
"""
|
|
68
|
+
return self.set_clipboard(bytes(str(text), 'UTF-8'), ClipboardContentType.PLAINTEXT, label)
|
|
69
|
+
|
|
70
|
+
def get_clipboard(self, content_type: str = ClipboardContentType.PLAINTEXT) -> bytes:
|
|
71
|
+
"""Receives the content of the system clipboard
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
content_type: One of ClipboardContentType items. Only ClipboardContentType.PLAINTEXT
|
|
75
|
+
is supported on Android
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Clipboard content as bytearray. Or empty bytes if the clipboard is empty
|
|
79
|
+
"""
|
|
80
|
+
ext_name = 'mobile: getClipboard'
|
|
81
|
+
options = {'contentType': content_type}
|
|
82
|
+
try:
|
|
83
|
+
base64_str = self.assert_extension_exists(ext_name).execute_script(ext_name, options)
|
|
84
|
+
except UnknownMethodException:
|
|
85
|
+
# TODO: Remove the fallback
|
|
86
|
+
base64_str = self.mark_extension_absence(ext_name).execute(Command.GET_CLIPBOARD, options)['value']
|
|
87
|
+
return base64.b64decode(base64_str)
|
|
88
|
+
|
|
89
|
+
def get_clipboard_text(self) -> str:
|
|
90
|
+
"""Receives the text of the system clipboard
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
The actual clipboard text or an empty string if the clipboard is empty
|
|
94
|
+
"""
|
|
95
|
+
return self.get_clipboard(ClipboardContentType.PLAINTEXT).decode('UTF-8')
|
|
96
|
+
|
|
97
|
+
def _add_commands(self) -> None:
|
|
98
|
+
self.command_executor.add_command(
|
|
99
|
+
Command.SET_CLIPBOARD,
|
|
100
|
+
'POST',
|
|
101
|
+
'/session/$sessionId/appium/device/set_clipboard',
|
|
102
|
+
)
|
|
103
|
+
self.command_executor.add_command(
|
|
104
|
+
Command.GET_CLIPBOARD,
|
|
105
|
+
'POST',
|
|
106
|
+
'/session/$sessionId/appium/device/get_clipboard',
|
|
107
|
+
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import List
|
|
16
|
+
|
|
17
|
+
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
18
|
+
|
|
19
|
+
from ..mobilecommand import MobileCommand as Command
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Context(CanExecuteCommands):
|
|
23
|
+
@property
|
|
24
|
+
def contexts(self) -> List[str]:
|
|
25
|
+
"""Returns the contexts within the current session.
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
driver.contexts
|
|
29
|
+
|
|
30
|
+
Return:
|
|
31
|
+
:obj:`list` of :obj:`str`: The contexts within the current session
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
return self.execute(Command.CONTEXTS)['value']
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def current_context(self) -> str:
|
|
38
|
+
"""Returns the current context of the current session.
|
|
39
|
+
|
|
40
|
+
Usage:
|
|
41
|
+
driver.current_context
|
|
42
|
+
|
|
43
|
+
Return:
|
|
44
|
+
str: The context of the current session
|
|
45
|
+
"""
|
|
46
|
+
return self.execute(Command.GET_CURRENT_CONTEXT)['value']
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def context(self) -> str:
|
|
50
|
+
"""Returns the current context of the current session.
|
|
51
|
+
|
|
52
|
+
Usage:
|
|
53
|
+
driver.context
|
|
54
|
+
|
|
55
|
+
Return:
|
|
56
|
+
str: The context of the current session
|
|
57
|
+
"""
|
|
58
|
+
return self.current_context
|
|
59
|
+
|
|
60
|
+
def _add_commands(self) -> None:
|
|
61
|
+
self.command_executor.add_command(Command.CONTEXTS, 'GET', '/session/$sessionId/contexts')
|
|
62
|
+
self.command_executor.add_command(Command.GET_CURRENT_CONTEXT, 'GET', '/session/$sessionId/context')
|
|
63
|
+
self.command_executor.add_command(Command.SWITCH_TO_CONTEXT, 'POST', '/session/$sessionId/context')
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
from selenium.common.exceptions import UnknownMethodException
|
|
18
|
+
|
|
19
|
+
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
20
|
+
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
21
|
+
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
22
|
+
|
|
23
|
+
from ..mobilecommand import MobileCommand as Command
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DeviceTime(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
27
|
+
@property
|
|
28
|
+
def device_time(self) -> str:
|
|
29
|
+
"""Returns the date and time from the device.
|
|
30
|
+
|
|
31
|
+
Return:
|
|
32
|
+
str: The date and time
|
|
33
|
+
"""
|
|
34
|
+
ext_name = 'mobile: getDeviceTime'
|
|
35
|
+
try:
|
|
36
|
+
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
37
|
+
except UnknownMethodException:
|
|
38
|
+
# TODO: Remove the fallback
|
|
39
|
+
return self.mark_extension_absence(ext_name).execute(Command.GET_DEVICE_TIME_GET, {})['value']
|
|
40
|
+
|
|
41
|
+
def get_device_time(self, format: Optional[str] = None) -> str:
|
|
42
|
+
"""Returns the date and time from the device.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
format: The set of format specifiers. Read https://momentjs.com/docs/
|
|
46
|
+
to get the full list of supported datetime format specifiers.
|
|
47
|
+
If unset, return :func:`.device_time` as default format is `YYYY-MM-DDTHH:mm:ssZ`,
|
|
48
|
+
which complies to ISO-8601
|
|
49
|
+
|
|
50
|
+
Usage:
|
|
51
|
+
| self.driver.get_device_time()
|
|
52
|
+
| self.driver.get_device_time("YYYY-MM-DD")
|
|
53
|
+
|
|
54
|
+
Return:
|
|
55
|
+
str: The date and time
|
|
56
|
+
"""
|
|
57
|
+
ext_name = 'mobile: getDeviceTime'
|
|
58
|
+
if format is None:
|
|
59
|
+
return self.device_time
|
|
60
|
+
try:
|
|
61
|
+
return self.assert_extension_exists(ext_name).execute_script(ext_name, {'format': format})
|
|
62
|
+
except UnknownMethodException:
|
|
63
|
+
return self.mark_extension_absence(ext_name).execute(Command.GET_DEVICE_TIME_POST, {'format': format})['value']
|
|
64
|
+
|
|
65
|
+
def _add_commands(self) -> None:
|
|
66
|
+
self.command_executor.add_command(
|
|
67
|
+
Command.GET_DEVICE_TIME_GET,
|
|
68
|
+
'GET',
|
|
69
|
+
'/session/$sessionId/appium/device/system_time',
|
|
70
|
+
)
|
|
71
|
+
self.command_executor.add_command(
|
|
72
|
+
Command.GET_DEVICE_TIME_POST,
|
|
73
|
+
'POST',
|
|
74
|
+
'/session/$sessionId/appium/device/system_time',
|
|
75
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, Optional, Union
|
|
16
|
+
|
|
17
|
+
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
18
|
+
|
|
19
|
+
from ..mobilecommand import MobileCommand as Command
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExecuteDriver(CanExecuteCommands):
|
|
23
|
+
# TODO Inner class case
|
|
24
|
+
def execute_driver(self, script: str, script_type: str = 'webdriverio', timeout_ms: Optional[int] = None) -> Any:
|
|
25
|
+
"""Run a set of script against the current session, allowing execution of many commands in one Appium request.
|
|
26
|
+
Please read http://appium.io/docs/en/commands/session/execute-driver for more details about the acceptable
|
|
27
|
+
scripts and the output format.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
script: The string consisting of the script itself
|
|
31
|
+
script_type: The name of the script type. Defaults to 'webdriverio'.
|
|
32
|
+
timeout_ms: The number of `ms` Appium should wait for the script to finish before
|
|
33
|
+
killing it due to timeout_ms.
|
|
34
|
+
|
|
35
|
+
Usage:
|
|
36
|
+
| self.driver.execute_driver(script='return [];')
|
|
37
|
+
| self.driver.execute_driver(script='return [];', script_type='webdriverio')
|
|
38
|
+
| self.driver.execute_driver(script='return [];', script_type='webdriverio', timeout_ms=10000)
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
ExecuteDriver.Result: The result of the script. It has 'result' and 'logs' keys.
|
|
42
|
+
|
|
43
|
+
Raises:
|
|
44
|
+
WebDriverException: If something error happens in the script. The message has the original error message.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
class Result:
|
|
48
|
+
def __init__(self, res: Dict):
|
|
49
|
+
self.result = res['result']
|
|
50
|
+
self.logs = res['logs']
|
|
51
|
+
|
|
52
|
+
option: Dict[str, Union[str, int]] = {'script': script, 'type': script_type}
|
|
53
|
+
if timeout_ms is not None:
|
|
54
|
+
option['timeout'] = timeout_ms
|
|
55
|
+
|
|
56
|
+
response = self.execute(Command.EXECUTE_DRIVER, option)['value']
|
|
57
|
+
return Result(response)
|
|
58
|
+
|
|
59
|
+
def _add_commands(self) -> None:
|
|
60
|
+
self.command_executor.add_command(Command.EXECUTE_DRIVER, 'POST', '/session/$sessionId/appium/execute_driver')
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict
|
|
16
|
+
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
|
|
19
|
+
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExecuteMobileCommand(CanExecuteScripts):
|
|
23
|
+
def press_button(self, button_name: str) -> Self:
|
|
24
|
+
"""Sends a physical button name to the device to simulate the user pressing.
|
|
25
|
+
|
|
26
|
+
iOS only.
|
|
27
|
+
Possible button names can be found in
|
|
28
|
+
https://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentLib/Categories/XCUIDevice%2BFBHelpers.h
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
button_name: the button name to be sent to the device
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
Union['WebDriver', 'ExecuteMobileCommand']: Self instance
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
data = {'name': button_name}
|
|
38
|
+
self.execute_script('mobile: pressButton', data)
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def battery_info(self) -> Dict[str, Any]:
|
|
43
|
+
"""Retrieves battery information for the device under test.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
`dict`: containing the following entries
|
|
47
|
+
level: Battery level in range [0.0, 1.0], where 1.0 means 100% charge.
|
|
48
|
+
Any value lower than 0 means the level cannot be retrieved
|
|
49
|
+
state: Platform-dependent battery state value.
|
|
50
|
+
On iOS (XCUITest):
|
|
51
|
+
1: Unplugged
|
|
52
|
+
2: Charging
|
|
53
|
+
3: Full
|
|
54
|
+
Any other value means the state cannot be retrieved
|
|
55
|
+
On Android (UIAutomator2):
|
|
56
|
+
2: Charging
|
|
57
|
+
3: Discharging
|
|
58
|
+
4: Not charging
|
|
59
|
+
5: Full
|
|
60
|
+
Any other value means the state cannot be retrieved
|
|
61
|
+
"""
|
|
62
|
+
return self.execute_script('mobile: batteryInfo')
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|