import unittest import time from typing import Dict, Any from appium import webdriver from appium.options.common import AppiumOptions from appium.webdriver.common.appiumby import AppiumBy from appium_flutter_finder import FlutterFinder, FlutterElement cap: Dict[str, Any] = { 'platformName': 'Android', 'automationName': 'flutter', 'uuid': '**********', 'platformVersion': '13', 'app': '/Users/test/Desktop/app-organization.apk', } appium_server_url = 'http://localhost:4723' driver = webdriver.Remote(appium_server_url, options=AppiumOptions().load_capabilities(cap)) ###############Flutter################################## #Change the context to FLUTTER driver.switch_to.context("NATIVE_APP") driver.switch_to.context("FLUTTER") #Init Fluttter finder class finder = FlutterFinder() key_finder = finder.by_text('start') button_element = FlutterElement(driver, key_finder) print(button_element.text) button_element.click() key_finder = finder.by_text("Skip") goto_next_route_element = FlutterElement(driver, key_finder) goto_next_route_element.click() ###############Flutter################################## ###############Native################################## driver.switch_to.context("NATIVE_APP") #Wait async operation time.sleep(2) driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/base_button").click() driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/et").send_keys('zzzzzzzzz') driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/btn_continue").click() driver.switch_to.context("FLUTTER") textfield_key_finder = finder.by_value_key("xNameTextFieldKey") textfield_element = FlutterElement(driver, textfield_key_finder) textfield_element.send_keys("Example Text") time.sleep(3) driver.implicitly_wait(20) driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/et_x").send_keys('x@y.com') driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/et_y").send_keys('53634643') driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/btn_z").click() driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/btn_a").click() driver.implicitly_wait(20) try: driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="Show me").click() except: driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/btn_w").click() try: driver.find_element(by=AppiumBy.ID, value="com.organization.app:id/btn_w").click() except: pass driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="Settings").click() driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="settingsTextKey").click() ###############Native################################## #Switch the context to FLUTTER ###############FLUTTER################################## driver.switch_to.context("FLUTTER") textfield_key_finder = finder.by_value_key("TextFieldKey") textfield_element = FlutterElement(driver, textfield_key_finder) textfield_element.send_keys("Example Text") time.sleep(3) textfield_element.clear() pw_key_finder = finder.by_value_key("extFieldKey") pw_element = FlutterElement(driver, pw_key_finder) pw_element.send_keys("58475684") time.sleep(10) driver.quit() if __name__ == '__main__': unittest.main() has context menu