# hypium-python-ui-test-skill **Repository Path**: qpcat/hypium-python-ui-test-skill ## Basic Information - **Project Name**: hypium-python-ui-test-skill - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-21 - **Last Updated**: 2026-04-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hypium Python UI Testing Skill Template A Hypium Python UI automation testing template project designed specifically for HarmonyOS application testing scenarios. ## Overview This project provides a complete Hypium Python UI automation testing framework template for developing UI automation test cases for HarmonyOS applications. Hypium is Huawei's core testing framework for HarmonyOS applications, supporting application operations, component positioning and interaction, swipe gestures, screenshot capture, and image recognition. ## Directory Structure ``` ├── config/ │ └── user_config.xml # User configuration file ├── doc/ │ └── hypium_api_6.0.7.210.md # Detailed API documentation ├── testcases/ │ └── ... # Test case directory ├── src/ │ └── ... # Source code directory ├── SKILL.md # Skill documentation └── main.py # Main entry point ``` ## Quick Start ### 1. Environment Preparation - Python 3.x - HarmonyOS device or emulator - Hypium testing framework ### 2. Connect Device ```python from hypium import UiDriver driver = UiDriver.connect() ``` ### 3. Create Test Case ```python #!/usr/bin/env python # coding: utf-8 import hypium from hypium import UiDriver from hypium.action import app from hypium.action import device def test_example(self, driver: UiDriver): """Example test case""" # Launch application driver.start_app("com.example.app") # Perform test operations driver.click(text="确定") # Stop application driver.stop_app("com.example.app") ``` ## Common APIs ### Application Operations ```python driver.start_app("com.example.app") # Launch application driver.stop_app("com.example.app") # Stop application driver.clear_app_data("com.example.app") # Clear application data driver.install_app("test.hap") # Install application driver.uninstall_app("com.example.app") # Uninstall application ``` ### Component Operations ```python driver.click(text="确定") # Click text component driver.click(id="confirm_button") # Click component by ID driver.double_click(text="确认") # Double-click driver.long_click(text="按钮", 5) # Long press for 5 seconds driver.input_text(id="input", "hello") # Input text driver.clear_text(id="input") # Clear text ``` ### Swipe Operations ```python driver.swipe_up() # Swipe up driver.swipe_down() # Swipe down driver.swipe_left() # Swipe left driver.swipe_right() # Swipe right driver.drag((100, 200), (300, 400)) # Drag ``` ### Wait Operations ```python driver.wait(5) # Wait 5 seconds driver.wait_for_component(id="button") # Wait for component to appear driver.wait_for_idle() # Wait for UI to become idle ``` ### Device Control ```python driver.press_key("power") # Press power key driver.press_home() # Press Home key driver.go_home() # Return to home screen driver.wake_up_display() # Wake up display ``` ### Screenshot Operations ```python driver.capture_screen("screen.png") # Take screenshot driver.take_screenshot() # Simulate screenshot ``` ### Window Operations ```python driver.find_window(bundle_name="com.example.app") driver.get_current_window() driver.check_window(bundle_name="com.example.app") ``` ## Test Configuration File The test case directory must include a configuration file. Refer to `config/user_config.xml` for configuration examples. ## Execution Method ### Command Line Execution ```bash python main.py ``` ## Notes 1. Test case scripts must end with `.py` 2. Ensure the device is properly connected 3. Use wait APIs to avoid failures due to overly rapid operations 4. Regularly clean test data to maintain a clean testing environment ## Development Workflow 1. **Syntax Check** - Ensure code syntax is correct 2. **Run Test Validation** - Execute tests on the device 3. **Review Results** - Check test logs to confirm execution status ## API Documentation Refer to the `doc/hypium_api_6.0.7.210.md` file for complete API documentation. ## License This project is for learning and communication purposes only.