### Install an Application Source: https://ctripcorp.github.io/flybirds Install an application on an Android device using the path to the APK file. This is specific to the Android platform. ```text 安装APP[/Users/xxx/xxx.apk] ``` -------------------------------- ### Install Flybirds Framework Source: https://ctripcorp.github.io/flybirds Use pip to install the flybirds framework and its dependencies. This command installs the core framework. ```bash pip3 install flybirds ``` -------------------------------- ### Install Default Browsers for Playwright Source: https://ctripcorp.github.io/flybirds Install all default browsers supported by Playwright. This command is used for setting up the Web testing environment. ```bash # 不带参数的运行将安装默认所有浏览器 playwright install ``` -------------------------------- ### View Available Playwright Browsers Source: https://ctripcorp.github.io/flybirds Display help information for the playwright install command, including a list of supported browsers that can be installed. ```bash # 查看支持安装的浏览器 playwright install --help ``` -------------------------------- ### Gherkin Scenario Outline with Examples Source: https://ctripcorp.github.io/flybirds Gherkin test case using Scenario Outline and Examples for data-driven parameterization of passenger module tests. ```gherkin 功能: 乘机人模块 @p1 @android @web 场景大纲: 外露乘机人_选择列表页乘机人 当 跳转页面到[单程填写页] 那么 页面渲染完成出现元素[已选乘机人姓名] 那么 的文案为 那么 存在[乘客类型标签儿童]的元素 那么 返回上一页 例子: | element | title | | 选择乘机人文案 | 选择乘机人 | | 已选乘机人姓名 | 李易峰 | | 已选乘机人证件类型 | 护照 | | 已选乘机人证件号 | YHE77 | ``` -------------------------------- ### Install iOS WebDriverAgent Source: https://ctripcorp.github.io/flybirds Instructions for installing and deploying iOS-Tagent using Xcode, enabling connection to iOS devices from Mac or Windows machines. This involves downloading project code and deploying it. ```bash brew install libimobiledevice ``` -------------------------------- ### Service Listen Mock Example Source: https://ctripcorp.github.io/flybirds Demonstrates how to listen to and mock service requests, including binding a mock case and removing the listener. ```zh-CN # language: zh-CN 功能: 监听并mock服务请求 场景: 服务监听与mock 假如 监听服务[movie]绑定MockCase[4245512] 当 跳转页面到[列表页] 那么 等待[10]秒 而且 移除服务监听[movie] 而且 移除所有服务监听 ``` -------------------------------- ### Launch an Application Source: https://ctripcorp.github.io/flybirds Start an application on Android or iOS devices by providing its package name. This is a common step for initiating app testing. ```text 启动APP[package name] ``` -------------------------------- ### Web Screen Recording Source: https://ctripcorp.github.io/flybirds Example for initiating and ending screen recording during web test execution. ```zh-CN # language: zh-CN 功能: web录屏 场景:录屏 假如 跳转页面到[百度] 而且 页面渲染完成出现元素[text=新闻] 而且 点击[#s-top-loginbtn] 而且 等待[10]秒 那么 结束录屏 ``` -------------------------------- ### Cache Service Request Examples Source: https://ctripcorp.github.io/flybirds Demonstrates how to interact with caching services, including making requests, removing specific caches, and removing all caches. ```zh-CN # language: zh-CN 功能: 缓存服务请求 场景:验证缓存服务请求 假如 缓存服务请求[getRecommendHotelList] 假如 缓存服务请求[writecookie] 而且跳转页面到[携程官网] 那么 等待[5]秒 而且 移除请求缓存[getRecommendHotelList] 而且 移除所有请求缓存 场景:验证缓存服务请求--同时传入多个参数 假如 缓存服务请求[getRecommendHotelList,writecookie] 而且 跳转页面到[携程官网] 那么 等待[5]秒 而且 移除请求缓存[getRecommendHotelList,writecookie] ``` -------------------------------- ### Basic Feature File Structure Source: https://ctripcorp.github.io/flybirds Example of a basic feature file structure within the 'features/test' directory. ```text features/ features/test/ features/test/everything.feature features/steps/ features/steps/steps.py ``` -------------------------------- ### Start iOS WebDriverAgent Proxy Source: https://ctripcorp.github.io/flybirds Start the wdaproxy for iOS devices to enable communication. This command requires the device UDID, WebDriverAgent bundle ID, and port. ```bash tidevice --udid $udid wdaproxy -B $web_driver_angnt_bundle_id -p $port ``` -------------------------------- ### Install Specific Browser for Playwright Source: https://ctripcorp.github.io/flybirds Install a specific browser, such as WebKit, for Playwright. This allows for targeted browser testing. ```bash # 通过提供一个参数来安装特定的浏览器 playwright install webkit ``` -------------------------------- ### Android - Start Screen Recording Source: https://ctripcorp.github.io/flybirds Initiates screen recording on the Android device. This should be called before the actions you wish to record. ```gherkin # language: zh-CN 功能: flybirds功能测试-android device record 场景: 验证设备录屏--录屏 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 而且 开始录屏 而且 点击[text=机票] 而且 等待[10]秒 那么 结束录屏 那么 关闭App ``` -------------------------------- ### Start Screen Recording Source: https://ctripcorp.github.io/flybirds Begins screen recording using the default timeout configured in the settings. Supports Android and iOS. ```javascript 开始录屏 ``` -------------------------------- ### Android - Start Screen Recording with Timeout Source: https://ctripcorp.github.io/flybirds Initiates screen recording with a specified timeout duration in seconds. If the timeout is reached before explicitly ending the recording, it will stop automatically. ```gherkin # language: zh-CN 功能: flybirds功能测试-android device record 场景:验证设备录屏--录屏超时 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 而且 开始录屏超时[50] 而且 点击文案[机票] 而且 等待[10]秒 那么 结束录屏 那么 关闭App ``` -------------------------------- ### Complex Feature File Structure Source: https://ctripcorp.github.io/flybirds An example of a more complex directory structure for feature files and their corresponding step implementations. ```text features/ features/test/ features/test/list.feature features/test/buy.feature features/test/detail.feature features/steps/ features/steps/steps.py ``` -------------------------------- ### Install Chinese Fonts (Ubuntu) Source: https://ctripcorp.github.io/flybirds Install necessary Chinese font packages on Ubuntu systems to ensure proper display of Chinese characters in test reports or logs. ```bash sudo apt-get install ttf-wqy-microhei #文泉驿-微米黑 sudo apt-get install ttf-wqy-zenhei #文泉驿-正黑 sudo apt-get install xfonts-wqy #文泉驿-点阵宋体 ``` -------------------------------- ### Gherkin Test Case Example Source: https://ctripcorp.github.io/flybirds Example of a Gherkin test case for the passenger module, specifying steps for navigation, element verification, and returning to the previous page. ```gherkin 功能: 乘机人模块 @p1 @android @web 场景:外露乘机人_选择列表页乘机人 当 跳转页面到[单程填写页] 那么 页面渲染完成出现元素[已选乘机人姓名] 那么 [选择乘机人文案]的文案为[选择乘机人] 那么 [已选乘机人姓名]的文案为[李易峰] 那么 [已选乘机人证件类型]的文案为[护照] 那么 [已选乘机人证件号]的文案为[YHE77] 那么 存在[乘客类型标签儿童]的元素 那么 返回上一页 ``` -------------------------------- ### Validate Service Request Examples Source: https://ctripcorp.github.io/flybirds Shows how to validate service requests, comparing JSON and non-JSON responses against expected data. ```zh-CN # language: zh-CN 功能: 验证比较服务请求 场景: json类型服务请求比对 假如 缓存服务请求[getRecommendHotelList] 而且 跳转页面到[携程官网] 那么 等待[5]秒 而且 验证服务[getRecommendHotelList]的请求参数[head.syscode]与[PC]一致 而且 验证服务[getRecommendHotelList]的请求参数[$.cityId]与[2]一致 而且 验证服务[getRecommendHotelList]的请求参数[cityId]与[2]一致 而且 验证服务请求[getRecommendHotelList]与[compareData/getRecommendHotelList.json]一致 场景: 非json类型服务请求比对 假如 缓存服务请求[writecookie] 而且 跳转到[携程官网] 那么 等待[5]秒 而且 验证服务非json请求[writecookie]与[compareData/writecookie.txt]一致 ``` -------------------------------- ### CI Integration Command for Jenkins Source: https://ctripcorp.github.io/flybirds Example shell command for Jenkins to execute Flybirds tests and copy reports to the workspace. ```bash # Inside the jenkins shell command cd {PATH_TO_PROJECT_FOLDER} # Run flybirds run -P ./features/test/everything.feature cp -R reports $WORKSPACE ``` -------------------------------- ### Run Android Tests Source: https://ctripcorp.github.io/flybirds Command to execute Android tests. Ensure your device is connected and recognized by 'adb devices'. The framework will automatically download and install the app. ```bash cd {PATH_TO_PROJECT_FOLDER} flybirds run -P features/test/android ``` -------------------------------- ### Start Screen Recording with Timeout Source: https://ctripcorp.github.io/flybirds Initiates screen recording with a specified timeout duration. Supports Android and iOS. Recording stops automatically if the timeout is reached. ```javascript 开始录屏超时[time] ``` -------------------------------- ### Web Element Verification Source: https://ctripcorp.github.io/flybirds Examples for verifying text content and attributes of web elements. ```zh-CN # language: zh-CN 功能: web元素属性验证 场景: 验证元素文案 假如 跳转页面到[百度] 那么 [text=新闻]的文案为[新闻] 那么 [text=新闻]的文案包含[新] 场景: 验证元素属性 假如 跳转页面到[百度] 那么 元素[#kw]的属性[name]为wd 那么 元素[#su]的属性[value]为百度一下 ``` -------------------------------- ### Grant Adb Execute Permission (Mac) Source: https://ctripcorp.github.io/flybirds On Mac systems, manually grant execute permissions to the adb file within the Airtest installation directory. This is necessary for Android device interaction. ```bash cd {your_python_path}/site-packages/airtest/core/android/static/adb/mac chmod +x adb ``` -------------------------------- ### iOS Swipe Actions Source: https://ctripcorp.github.io/flybirds Provides examples for performing swipe gestures on iOS, including swiping specific elements or the entire screen, with options for direction and distance. ```zh-CN # language: zh-CN 功能: flybirds功能测试-ios swipe 场景: 验证滑动--元素滑动 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=租车] 而且 [label=租车]向上滑动[600] 而且 等待[5]秒 那么 元素[label=租车]位置[5]秒内未变动 那么 存在元素[label=租车] 那么 存在[租车]的元素 场景: 验证滑动--全屏滑动 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=租车] 而且 全屏向上滑动[600, readyTime=3, duration=2] 那么 不存在[label=机票]的元素 那么 不存在[升级攻略]的文案 那么 元素[label=机票]消失 那么 文案[搜索]消失 ``` -------------------------------- ### Grant Adb Execute Permission (Linux) Source: https://ctripcorp.github.io/flybirds On Linux systems, manually grant execute permissions to the adb file within the Airtest installation directory. This is necessary for Android device interaction. ```bash cd {your_python_path}/site-packages/airtest/core/android/static/adb/linux chmod +x adb ``` -------------------------------- ### Android - Find Element Downwards Source: https://ctripcorp.github.io/flybirds Searches for a UI element with specific text content within the current view hierarchy, starting from the current context and moving downwards. ```gherkin # language: zh-CN 功能: flybirds功能测试-android find element 场景: 验证元素操作--在全屏查找 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 那么 向下查找[text=租车]的元素 ``` -------------------------------- ### Run All Feature Files Source: https://ctripcorp.github.io/flybirds Execute all feature files located in the 'features' directory. This is the default behavior when no specific path is provided. ```bash cd {PATH_TO_PROJECT_FOLDER} flybirds run # 运行所有feature ``` -------------------------------- ### Web Dropdown Selection Source: https://ctripcorp.github.io/flybirds Demonstrates how to select an option from a dropdown list in a web application using its selector and the desired option text. ```zh-CN # language: zh-CN 功能: 下拉框 场景: 下拉框选择 假如 跳转页面到[携程] 而且 在[#J_roomCountList]中选择[6间] 而且 等待[5]秒 那么 结束录屏 ``` -------------------------------- ### Plugin Configuration for Custom Screen Extension Source: https://ctripcorp.github.io/flybirds JSON configuration snippet for 'plugin_info.json' to specify a custom path and namespace for extending the web screen functionality. ```json "screen": { "path": "{local_path}/screen.py", "ns": "screen.plugin.myextend" } ``` -------------------------------- ### Create a New Flybirds Project Source: https://ctripcorp.github.io/flybirds Use the flybirds CLI scaffold to create a new project. This command initializes a new project structure. ```bash flybirds create ``` -------------------------------- ### Web Click Actions Source: https://ctripcorp.github.io/flybirds Demonstrates various click actions for web elements, including clicking by CSS selector, by text content, and by screen coordinates. ```zh-CN # language: zh-CN 功能: web点击 场景: 点击元素 假如 跳转页面到[百度] 而且 点击[#s-top-loginbtn] 而且 等待[3]秒 那么 全屏截图 场景: 点击文案 假如 跳转页面到[百度] 而且 点击文案[新闻] 而且 等待[3]秒 那么 全屏截图 场景: 点击屏幕位置 假如 跳转页面到[百度] 而且 点击屏幕位置[720,400] 而且 等待[3]秒 那么 全屏截图 ``` -------------------------------- ### Browser Configuration for Multi-Browser Testing Source: https://ctripcorp.github.io/flybirds Configuration object for 'web_info' specifying browser types (firefox, chromium, webkit) and other settings like headless mode and default timeout. ```json // browserType: 配置浏览器内核 "web_info": { "headless": true, "browserType": ["firefox","chromium","webkit"], "defaultTimeout": 30 }, ``` -------------------------------- ### Log in with Username and Password Source: https://ctripcorp.github.io/flybirds Perform a login action using provided username and password. This functionality is typically custom-implemented in `pscript/app/operation.py`. ```text 登录账号[{param1}]密码[{param2}] ``` -------------------------------- ### Connect to a Test Device Source: https://ctripcorp.github.io/flybirds Connect to a test device using its IP address and port. This command is supported on Android and iOS platforms. ```text 连接设备[10.21.37.123:5555] ``` -------------------------------- ### Override Configuration with Custom Parameters Source: https://ctripcorp.github.io/flybirds Pass custom parameters to override configuration values, such as switching the execution platform (Android, iOS, Web). ```bash # 通过参数切换执行平台Android、iOS、Web flybirds run --define platform=web ``` -------------------------------- ### Display Flybirds Run Command Help Source: https://ctripcorp.github.io/flybirds Show the help message for the 'flybirds run' command, detailing all available options and arguments for executing test cases. ```bash flybirds run --help ``` -------------------------------- ### Get Element Attribute Value Source: https://ctripcorp.github.io/flybirds Retrieves the value of a specified attribute for a given element. Supports Android, iOS, and Web. The `timeout` parameter specifies the maximum time to wait for the element. ```javascript 元素[text=机票]的属性[text]为机票 ``` ```javascript 元素[text=机票, timeout=15]的属性[text, dealMethod=trim_last]为机 ``` -------------------------------- ### Configure MockCase Data via Function Call Source: https://ctripcorp.github.io/flybirds Allows custom retrieval of MockData by implementing the `get_mock_case_body` function in `pscript/custom_handle/operation.py`. If the function returns None, the framework falls back to JSON file configuration. ```python # In pscript/custom_handle/operation.py def get_mock_case_body(mock_case_id): # Custom logic to fetch or generate mock data pass ``` -------------------------------- ### Run Android Feature Files Source: https://ctripcorp.github.io/flybirds Execute all feature files specifically for the Android platform. This command targets features located in the specified Android directory. ```bash flybirds run -P features/test/android # 运行所有android feature ``` -------------------------------- ### Run Scenarios with Specific Tags Source: https://ctripcorp.github.io/flybirds Execute test scenarios that have specific tags. Multiple tags can be specified, and tags can be excluded using a '-' prefix. ```bash flybirds run -T tag1,tag2,-tag3,tag4 ``` -------------------------------- ### Run iOS Feature Files Source: https://ctripcorp.github.io/flybirds Execute all feature files specifically for the iOS platform. This command targets features located in the specified iOS directory. ```bash flybirds run -P features/test/ios # 运行所有ios feature ``` -------------------------------- ### iOS Click Actions Source: https://ctripcorp.github.io/flybirds Demonstrates different ways to perform click actions on iOS elements, including by position, by element label, and in conjunction with input. ```zh-CN # language: zh-CN 功能: flybirds功能测试-ios click 场景: 验证点击--点击屏幕位置 当 启动APP[com.ctrip.inner.wireless] 而且 点击屏幕位置[580,1200] 而且 等待[5]秒 那么 全屏截图 那么 关闭App 场景: 验证点击--点击元素 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=机票] 而且 点击[label=机票] 那么 全屏截图 场景: 验证点击--点击并输入 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=搜索] 而且 在[label=搜索]中输入[flybirds] 而且 等待[10]秒 那么 全屏截图 ``` -------------------------------- ### Web Input Actions Source: https://ctripcorp.github.io/flybirds Shows how to perform input operations on web elements, including typing text and clearing the field before inputting new text. ```zh-CN # language: zh-CN 功能: 输入操作 场景: 输入 假如 跳转页面到[百度] 而且 在[#kw]中输入[flybirds] 而且 等待[3]秒 那么 全屏截图 场景: 清空并输入 假如 跳转页面到[百度] 而且 在[#kw]中输入[flybirds] 而且 等待[3]秒 那么 在[#kw]中清空并输入[input test] 那么 全屏截图 ``` -------------------------------- ### Assert Text Does Not Exist Source: https://ctripcorp.github.io/flybirds Use this command to verify that specific text is not present on the page. Supports fuzzy matching. ```javascript 不存在[机票]的文案 ``` ```javascript 不存在[.?票, fuzzyMatch=true]的文案 ``` -------------------------------- ### Run Specific Feature File Source: https://ctripcorp.github.io/flybirds Execute a single, specific feature file. This allows for targeted testing of a particular scenario. ```bash flybirds run -P ./features/test/demo.feature ``` -------------------------------- ### Navigate to Page Source: https://ctripcorp.github.io/flybirds Navigates to a specified page using its schema URL, which should be defined in `config/schema_url.json`. Supports Android and Web. ```javascript 跳转到[首页] ``` -------------------------------- ### Page Object Element Locator Configuration (Platform Specific) Source: https://ctripcorp.github.io/flybirds JSON configuration for element locators that are specific to Android, iOS, or Web platforms. ```json // 元素定位配置 ele_locator.json { “乘客类型标签儿童”: { “android”: “textid=passger_type_child”, “ios”: “lableid=passger_type_child”, “web”: “xpath=//html/body/div” } } ``` -------------------------------- ### Command to Run Tests with Specific Browsers Source: https://ctripcorp.github.io/flybirds Command-line instruction to execute tests using Flybirds, specifying the browser types to be used for web execution. ```bash # 通过参数指定web执行平台启动的浏览器(多个浏览器时用半角逗号进行分隔) flybirds run -D browserType=webkit,firefox ``` -------------------------------- ### Configure Schema URLs for Multi-Platform Pages Source: https://ctripcorp.github.io/flybirds Use this JSON configuration to unify schema access URLs for pages across different platforms. It allows for different URLs based on the platform (android, ios, web). ```json "列表页": { "android": "/rn_test/ctrip_list_android/", "ios": "/rn_test/ctrip_list_ios/", "web": "https://ctrip.test/list" } ``` -------------------------------- ### Configure MockCase Data via JSON File Source: https://ctripcorp.github.io/flybirds Defines mock response data for service operations using a JSON file. Ensure the mockCaseId (JSON key) is unique across all mockCaseData JSON files to prevent overwrites. ```json { "4245512": { "count": 101, "results": [ { "id": 10, "name": "test-狮子王", "alias": "The Lion King", "cover": "https://p0.meituan.net/movie/27b76fe6cf3903f3d74963f70786001e1438406.jpg@464w_644h_1e_1c", "categories": [ "动画", "歌舞", "冒险" ], "published_at": "1995-07-15", "minute": 89, "score": 9.0, "regions": [ "美国" ] } ] } } ``` -------------------------------- ### Restart Application Source: https://ctripcorp.github.io/flybirds Restart the currently running application. This action is supported on both Android and iOS. ```text 重启APP ``` -------------------------------- ### Specify Maximum Concurrent Processes for Web Source: https://ctripcorp.github.io/flybirds Set the maximum number of concurrent processes for test execution. This option is only effective for the Web platform. ```bash flybirds run --path features -p 5 ``` -------------------------------- ### Check Android Device Connection Source: https://ctripcorp.github.io/flybirds Verify that Android devices are connected and recognized by the system. This command lists connected devices. ```bash adb devices ``` -------------------------------- ### Specify Test Result Format Source: https://ctripcorp.github.io/flybirds Define the output format for test results. The default format is JSON. ```bash #默认 flybirds run --format=json ``` -------------------------------- ### Web Find Element Actions Source: https://ctripcorp.github.io/flybirds Illustrates how to find elements on a web page, either by searching the entire page or by locating a child element within a specific parent. ```zh-CN # language: zh-CN 功能: web查找元素 场景: 在全屏查找 假如 跳转页面到[百度] 而且 页面渲染完成出现元素[text=新闻] 那么 向下查找[text=关于百度]的元素 场景: 在父元素中查找子元素 假如 跳转页面到[百度] 那么 存在[#hotsearch-content-wrapper]的[li.hotsearch-item.odd[data-index="2"]]的元素 那么 [.s-bottom-layer-content]的[text=帮助中心]文案为[帮助中心] ``` -------------------------------- ### Create Custom DSL Steps in Python Source: https://ctripcorp.github.io/flybirds Extend Flybirds functionality by creating custom DSL steps in Python. Place your custom step definitions in `.py` files within the `pscript/dsl/steps` directory and import them in `feature/steps/steps.py`. ```python pscript/dsl/steps ``` -------------------------------- ### Check iOS Device Connection Source: https://ctripcorp.github.io/flybirds Verify that iOS devices are connected and recognized using the tidevice library. This command lists connected devices. ```bash tidevice list ``` -------------------------------- ### Log out of the System Source: https://ctripcorp.github.io/flybirds Perform a logout action to exit the current user session. This is a custom implementation usually found in `pscript/app/operation.py`. ```text 退出登录 ``` -------------------------------- ### Assert Element Does Not Exist Source: https://ctripcorp.github.io/flybirds Use this command to verify that an element identified by a selector does not exist on the page. Supports various selector types and multi-selector. ```javascript 不存在[center_content_layout]的元素 ``` ```javascript 不存在[text=经济舱]的元素 ``` ```javascript 不存在textMatches=.?经济舱并且type=android.view.ViewGroup, multiSelector=true]的元素 ``` ```javascript 不存在[机票→第1个兄弟节点, path=true]的元素 ``` -------------------------------- ### Project Directory Structure Source: https://ctripcorp.github.io/flybirds This shows the default directory structure for a Flybirds project, including where to place feature files and step implementations. ```text features/test/ features/test/android features/test/android/cn/everything.feature features/test/android/en/everything.feature features/test/ios features/test/ios/cn/everything.feature features/test/ios/en/everything.feature ``` -------------------------------- ### Configure Element Locators for Multi-Platform Elements Source: https://ctripcorp.github.io/flybirds This JSON configuration standardizes element locator strategies for elements across different platforms. It supports distinct locators for android, ios, and web. ```json "元素2": { "android": "text=机票", "ios": "label=机票", "web": "#s-top-loginbtn" } ``` -------------------------------- ### Listen to Service Operations and Bind MockCase Source: https://ctripcorp.github.io/flybirds Intercepts requests for specified operations and replaces responses with mock data from a given MockCase ID. Operations are identified by the string between the last '/' and '?' in the URL. ```gherkin 监听服务[movie]绑定MockCase[4245512] ``` ```gherkin 监听服务[movie,testList]绑定MockCase[4245512,123456] ``` -------------------------------- ### Web Page Navigation and Verification Source: https://ctripcorp.github.io/flybirds Covers page navigation actions like going back and verifying the current page state in web applications. ```zh-CN # language: zh-CN 功能: 页面操作 场景: 返回上一页 假如 跳转页面到[列表页] 而且 页面渲染完成出现元素[text=霸王别姬 - Farewell My Concubine] 而且 点击[text=霸王别姬 - Farewell My Concubine] 而且 等待[3]秒 而且 返回上一页 而且 等待[2]秒 那么 结束录屏 场景: 判断当前页面 假如 跳转页面到[列表页] 而且 页面渲染完成出现元素[text=霸王别姬 - Farewell My Concubine] 而且 点击[text=霸王别姬 - Farewell My Concubine] 而且 等待[3]秒 那么 当前页面是[列表详情页] ``` -------------------------------- ### Assert Text Exists Source: https://ctripcorp.github.io/flybirds Use this command to check if specific text exists on the page. Supports fuzzy matching and timeouts. ```javascript 存在[机票]的文案 ``` ```javascript 存在[机票, timeout=10]的文案 ``` ```javascript 存在[.?票, fuzzyMatch=true]的文案 ``` -------------------------------- ### Page Object Schema URL Configuration (JSON) Source: https://ctripcorp.github.io/flybirds JSON configuration for schema URLs, used when page objects differ across platforms (Android, iOS, Web). ```json // scheme配置 schema_url.json { “单程填写页”: { “android”: “urlschemel://auth_activity”, “ios”: “urlschemel://ios_auth_activity”, “web”: “https://address” } } ``` -------------------------------- ### Page Object Element Locator Configuration (JSON) Source: https://ctripcorp.github.io/flybirds JSON configuration for element locators used in page object management. This is used when elements are the same across different platforms. ```json // 元素定位配置 ele_locator.json { "选择乘机人文案": “testid=passger_check”, "已选乘机人姓名": “testid=passger_name_checked”, "已选乘机人证件类型": “testid=passger_ct_checked”, "已选乘机人证件号": “testid=passger_cn_checked” } ``` -------------------------------- ### iOS Element Verification Source: https://ctripcorp.github.io/flybirds Shows how to verify element text content and attributes on iOS to ensure correctness. ```zh-CN # language: zh-CN 功能: flybirds功能测试-ios verify element 场景: 验证元素--元素文案 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=机票] 那么 [label=机票]的文案为[机票] 那么 [label=机票]的文案包含[机] 场景: 验证元素--元素属性 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=机票] 那么 元素[label=机票]的属性[label]为机票 ``` -------------------------------- ### iOS Find Element Actions Source: https://ctripcorp.github.io/flybirds Illustrates how to locate elements within the iOS application, either within a specific container like ScrollView or across the entire screen. ```zh-CN # language: zh-CN 功能: flybirds功能测试-ios find element 场景: 验证元素操作--在页面中查找 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=机票] 那么 在[ScrollView]中向下查找[label=租车]的元素 场景: 验证元素操作--在全屏查找 当 启动APP[com.ctrip.inner.wireless] 而且 页面渲染完成出现元素[label=机票] 那么 向下查找[label=租车]的元素 ``` -------------------------------- ### Android - Click Screen Position Source: https://ctripcorp.github.io/flybirds Simulates a tap on the screen at specific coordinates. Used for interacting with UI elements when direct element identification is not feasible or necessary. ```gherkin # language: zh-CN 功能: flybirds功能测试-android click 场景: 验证点击--点击屏幕位置 当 启动APP[ctrip.android.view] 而且 点击屏幕位置[580,1200] 而且 等待[5]秒 那么 全屏截图 那么 关闭App ``` -------------------------------- ### Assert Page Rendered with Element Source: https://ctripcorp.github.io/flybirds Use this command to determine if a page has finished rendering by checking for the presence of a specific element. Supports timeouts. ```javascript 页面渲染完成出现元素[text=机票] ``` ```javascript 页面渲染完成出现元素[center_content_layout, timeout=15] ``` ```javascript 页面渲染完成出现元素[center_content_layout, timeout=40] ``` -------------------------------- ### Configure Ignored Nodes for Service Request Validation Source: https://ctripcorp.github.io/flybirds Specifies nodes to ignore during service request validation, either by exact path or by regular expression. Configuration is done via JSON files in the `interfaceIgnoreConfig` directory. ```json { "getRecommendHotelList": [ "head.cid", "regex: root\['head'\]\['extension'\]\[\d+\]\['value'\]" ], "writecookie": [ "token" ] } ``` -------------------------------- ### Flybirds i18n Configuration File Path Source: https://ctripcorp.github.io/flybirds Indicates the file path within the Flybirds core library where language configurations for globalization are managed. ```python flybirds/core/dsl/globalization/i18n.py ``` -------------------------------- ### Run Scenarios with Specific Tags Source: https://ctripcorp.github.io/flybirds Use the `flybirds run -T` command to execute scenarios tagged with specific identifiers. Multiple tags can be comma-separated. To exclude scenarios with a tag, prefix it with a hyphen. ```bash flybirds run -T tag1,tag2 ``` ```bash flybirds run -T -tag ``` -------------------------------- ### Android - Click Element by Text Source: https://ctripcorp.github.io/flybirds Simulates a tap on a UI element identified by its text content. Requires the element to be visible on the screen. ```gherkin # language: zh-CN 功能: flybirds功能测试-android click 场景: 验证点击--点击元素 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 而且 点击[text=机票] 那么 全屏截图 ``` -------------------------------- ### Define Hooks in Python Source: https://ctripcorp.github.io/flybirds Define custom hooks in Python files to execute code before or after specific test events like steps, scenarios, features, or tags. The `hook.py` file is a common location for these definitions. ```python pscript/dsl/step/hook.py ``` -------------------------------- ### Slide Element Source: https://ctripcorp.github.io/flybirds Performs a sliding gesture within a specified container element. Supports Android, iOS, and Web. Parameters like `startX`, `startY`, `duration`, and `readyTime` control the slide behavior. ```javascript [containerEleId]向左滑动[0.1] ``` ```javascript [containerEleId]向上滑动[100, duration=5, readyTime=3] ``` ```javascript [containerEleId]向上滑动[100, startX=0.2, startY=0.4, duration=5, readyTime=3] ``` -------------------------------- ### Click Screen Position Source: https://ctripcorp.github.io/flybirds Perform a click action at a specific coordinate on the screen. ```javascript 点击屏幕位置[200,100] ``` -------------------------------- ### Dynamic Loading of Plugin Packages Source: https://ctripcorp.github.io/flybirds Flybirds supports dynamic loading of custom functionality through plugin packages. Ensure your package name includes '-flybirds-plugin' for it to be recognized. ```text package naming contains "-flybirds-plugin" ``` -------------------------------- ### Take Full Screen Screenshot Source: https://ctripcorp.github.io/flybirds Captures a screenshot of the entire screen and attaches it to the test report. Supports Android, iOS, and Web. ```javascript 全屏截图 ``` -------------------------------- ### Input Text into Element Source: https://ctripcorp.github.io/flybirds Enters specified text into an input element identified by a selector. Supports Android, iOS, and Web. `pocoInput` can be used to switch to POCO input method, and `afterInputWait` sets a delay after input. ```javascript 在[inputEleId]中输入[上海] ``` ```javascript 在[type=InputView]中输入[用户名, pocoInput=true, afterInputWait=5] ``` -------------------------------- ### Android - Verify Element Text Source: https://ctripcorp.github.io/flybirds Asserts that the text displayed by a UI element exactly matches or contains a specified string. Useful for verifying labels, buttons, and other text-based elements. ```gherkin # language: zh-CN 功能: flybirds功能测试-android verify element 场景: 验证元素--元素文案 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 那么 [text=机票]的文案为[机票] 那么 [text=机票]的文案包含[机] ``` -------------------------------- ### Android - Find Element by Text Source: https://ctripcorp.github.io/flybirds Locates a UI element on the screen based on its text content. This is a prerequisite for interacting with the element. ```gherkin # language: zh-CN 功能: flybirds功能测试-android find element 场景: 验证元素操作--在页面中查找 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 那么 在[android.widget.LinearLayout]中向下查找[text=机票]的元素 ``` -------------------------------- ### Assert Text Disappears Source: https://ctripcorp.github.io/flybirds Use this command to wait for specific text to disappear from the page within a given timeout. Supports fuzzy matching. ```javascript 文案[机票]消失 ``` ```javascript 文案[.?票, fuzzyMatch=true, timeout=20]消失 ``` -------------------------------- ### Delete an Application Source: https://ctripcorp.github.io/flybirds Remove an application from an Android device by specifying its package name. This action is only supported on Android. ```text 删除APP[package name] ``` -------------------------------- ### Full Screen Slide Source: https://ctripcorp.github.io/flybirds Performs a sliding gesture across the entire screen. Supports Android, iOS, and Web. `duration` and `readyTime` can be specified to control the slide timing. ```javascript 向上滑动[0.05] ``` ```javascript 向下滑动[0.4, readyTime=3, duration=2] ``` -------------------------------- ### Web Swipe Actions Source: https://ctripcorp.github.io/flybirds Covers both element-specific and full-page swipe gestures on web pages, including direction and distance. ```zh-CN # language: zh-CN 功能: web滑动 场景: 滑动 假如 跳转页面到[列表页] 而且 等待[2]秒 而且 [text=霸王别姬 - Farewell My Concubine]向下滑动[600] 而且 等待[5]秒 那么 存在元素[text=肖申克的救赎 - The Shawshank Redemption] 那么 存在[肖申克的救赎 - The Shawshank Redemption]的文案 场景:全屏滑动 假如 跳转页面到[列表页] 而且 等待[2]秒 而且 全屏向下滑动[600] 而且 等待[5]秒 那么 不存在[text=测试]的元素 那么 不存在[测试]的文案 ``` -------------------------------- ### Assert Element Exists Source: https://ctripcorp.github.io/flybirds Use this command to check if an element identified by a selector exists on the page. Supports various selector types, multi-selector, and timeouts. ```javascript 存在[center_content_layout]的元素 ``` ```javascript 存在[text=经济舱]的元素 ``` ```javascript 存在[textMatches=.?经济舱]的元素 ``` ```javascript 存在[textMatches=.?经济舱并且type=android.view.ViewGroup, multiSelector=true, timeout=30]的元素 ``` ```javascript 存在[机票→第1个兄弟节点, path=true]的元素 ``` -------------------------------- ### Assert Element Text Equals Source: https://ctripcorp.github.io/flybirds Verify that the text content of an element matches a specific string. Supports fuzzy matching, timeouts, and attribute manipulation methods. ```javascript [text=机票]的文案为[机票] ``` ```javascript [textMatches=.?经济舱, timeout=15]的文案为[经济舱, dealMethod=trim_prefix] ``` ```javascript [textMatches=.?经济舱并且visible=True, multiSelector=true, timeout=15]的文案为[经济舱, dealMethod=trim_prefix] ``` -------------------------------- ### Validate Service Request Against Data File Source: https://ctripcorp.github.io/flybirds Compares the cached response of a service operation with the content of a specified data file. Operations are identified by the string between the last '/' and '?' in the URL. ```gherkin 验证服务请求[getRecommendHotelList]与[compareData/getRecommendHotelList.json]一致 ``` -------------------------------- ### Android - Input Text into Element Source: https://ctripcorp.github.io/flybirds Enters text into a specified UI element, typically a text input field. The element is identified by its text content. ```gherkin # language: zh-CN 功能: flybirds功能测试-android click 场景: 验证点击--点击并输入 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=搜索] 而且 在[text=搜索]中输入[flybirds] 而且 等待[10]秒 那么 全屏截图 ``` -------------------------------- ### Android - Verify Element Attribute Source: https://ctripcorp.github.io/flybirds Checks if a specific attribute of a UI element has a given value. This is useful for verifying properties like 'text', 'content-desc', or custom attributes. ```gherkin # language: zh-CN 功能: flybirds功能测试-android verify element 场景: 验证元素--元素属性 当 启动APP[ctrip.android.view] 而且 页面渲染完成出现元素[text=机票] 那么 元素[text=机票]的属性[text]为机票 ``` -------------------------------- ### Verify Element Position Stability Source: https://ctripcorp.github.io/flybirds Checks if an element's position remains unchanged for a specified duration. Primarily used to determine if the page is not scrolling. Supports Android and iOS. `verifyCount` sets the maximum number of checks. ```javascript 元素[选择器]位置[time]秒内未变动 ```