I am trying to automate a Flutter app using Flutter Finder, but I am getting “unknown locator” for each and every Flutter element

I am trying to automate flutter app using java and flutter finder but I am getting unknown locator for each and every flutter element. Here I am attaching java code. Please let me know what is the problem here.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>public class FlutterAutomation {
private static AndroidDriver driver;
private static final String appPath = "C:\Users\NMAHESHBABU\flutterlogin-debug.apk";
private final String deviceName = "Pixel 3 API 29";
private final String testName = "Flutter Automation";
@BeforeTest
public void setUp() throws MalformedURLException {
DesiredCapabilities flutterCapabilities = new DesiredCapabilities();
flutterCapabilities.setCapability("deviceName", deviceName);
flutterCapabilities.setCapability("platformName", "Android");
flutterCapabilities.setCapability("automationName", "flutter");
flutterCapabilities.setCapability("app", appPath);
flutterCapabilities.setCapability("noReset", true);
flutterCapabilities.setCapability("testName", testName);
driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), flutterCapabilities);
System.out.println("Created AppiumDriver");
}
@Test
public void checkLoginFunction() throws Exception {
FlutterFinder find = new FlutterFinder(driver);
Thread.sleep(3000);
FlutterElement txt_username = find.byValueKey("txt_username"); // this is valid locator
FlutterElement txt_password = find.byValueKey("txt_pass"); // this is not a valid locator actual locator is txt_password
FlutterElement btn_click = find.byValueKey("button_login");// this is valid locator
System.out.println(txt_username);
System.out.println(txt_password);
txt_username.sendKeys("[email protected]");
txt_password.sendKeys("user123");
btn_click.click();
}
@AfterTest
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
}
</code>
<code>public class FlutterAutomation { private static AndroidDriver driver; private static final String appPath = "C:\Users\NMAHESHBABU\flutterlogin-debug.apk"; private final String deviceName = "Pixel 3 API 29"; private final String testName = "Flutter Automation"; @BeforeTest public void setUp() throws MalformedURLException { DesiredCapabilities flutterCapabilities = new DesiredCapabilities(); flutterCapabilities.setCapability("deviceName", deviceName); flutterCapabilities.setCapability("platformName", "Android"); flutterCapabilities.setCapability("automationName", "flutter"); flutterCapabilities.setCapability("app", appPath); flutterCapabilities.setCapability("noReset", true); flutterCapabilities.setCapability("testName", testName); driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), flutterCapabilities); System.out.println("Created AppiumDriver"); } @Test public void checkLoginFunction() throws Exception { FlutterFinder find = new FlutterFinder(driver); Thread.sleep(3000); FlutterElement txt_username = find.byValueKey("txt_username"); // this is valid locator FlutterElement txt_password = find.byValueKey("txt_pass"); // this is not a valid locator actual locator is txt_password FlutterElement btn_click = find.byValueKey("button_login");// this is valid locator System.out.println(txt_username); System.out.println(txt_password); txt_username.sendKeys("[email protected]"); txt_password.sendKeys("user123"); btn_click.click(); } @AfterTest public void tearDown() { if (driver != null) { driver.quit(); } } } </code>
public class FlutterAutomation {

    private static AndroidDriver driver;
    private static final String appPath = "C:\Users\NMAHESHBABU\flutterlogin-debug.apk";
    private final String deviceName = "Pixel 3 API 29";
    private final String testName = "Flutter Automation";
    
    
    @BeforeTest
    public void setUp() throws MalformedURLException {
        DesiredCapabilities flutterCapabilities = new DesiredCapabilities();
        flutterCapabilities.setCapability("deviceName", deviceName);
        flutterCapabilities.setCapability("platformName", "Android");
        flutterCapabilities.setCapability("automationName", "flutter");
        flutterCapabilities.setCapability("app", appPath);
        flutterCapabilities.setCapability("noReset", true);
        flutterCapabilities.setCapability("testName", testName);
        driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), flutterCapabilities);
        System.out.println("Created AppiumDriver");
    }

    @Test
    public void checkLoginFunction() throws Exception {
        FlutterFinder find = new FlutterFinder(driver);
        Thread.sleep(3000);
        FlutterElement txt_username = find.byValueKey("txt_username"); // this is valid locator
        FlutterElement txt_password = find.byValueKey("txt_pass"); // this is not a valid locator actual locator is txt_password
        FlutterElement btn_click = find.byValueKey("button_login");// this is valid locator
        System.out.println(txt_username);
        System.out.println(txt_password);
        
        txt_username.sendKeys("[email protected]");
        txt_password.sendKeys("user123");
        btn_click.click();
    }
    

    @AfterTest
    public void tearDown() {
        if (driver != null) {
            driver.quit();
        }
    }

}

Output:

[RemoteTestNG] detected TestNG version 7.4.0
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Created AppiumDriver
[io.github.ashwith.flutter.FlutterElement@6cfedde -> unknown locator]
[io.github.ashwith.flutter.FlutterElement@8343364 -> unknown locator]
FAILED: checkLoginFunction
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: ‘4.13.0’, revision: ‘ba948ece5b*’
System info: os.name: ‘Windows 11’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘17.0.2’
Driver info: io.appium.java_client.android.AndroidDriver
Command: [f457e47b-31f2-4c5c-af08-1f94839dbe02, sendKeysToElement [id, value]]
Capabilities {appium:address: 127.0.0.1, appium:allowCors: false, appium:allowInsecure: [], appium:androidCoverage: false, appium:app: C:UsersNMAHESHBABUflutte…, appium:appWaitActivity: false, appium:appWaitPackage: false, appium:automationName: flutter, appium:backendRetries: 3, appium:basePath: /wd/hub, appium:bootstrapPort: 4724, appium:debugLogSpacing: false, appium:defaultCapabilities: {}, appium:defaultCommandTimeout: 60, appium:defaultDevice: false, appium:denyInsecure: [], appium:deviceName: Pixel 3 API 29, appium:deviceReadyTimeout: 5, appium:dontStopAppOnReset: false, appium:enforceStrictCaps: false, appium:fastReset: false, appium:forceIpad: false, appium:forceIphone: false, appium:fullReset: false, appium:intentAction: android.intent.action.MAIN, appium:intentCategory: android.intent.category.LAU…, appium:intentFlags: 0x10200000, appium:isolateSimDevice: false, appium:keepArtifacts: false, appium:keepKeyChains: false, appium:keyAlias: androiddebugkey, appium:keyPassword: android, appium:keystorePassword: android, appium:keystorePath: C:UsersNMAHESHBABU.andro…, appium:launch: false, appium:launchTimeout: 90000, appium:localTimezone: false, appium:localizableStringsDir: en.lproj, appium:logNoColors: false, appium:logTimestamp: false, appium:loglevel: debug, appium:longStacktrace: false, appium:nativeInstrumentsLib: false, appium:noPermsCheck: false, appium:noReset: true, appium:port: 4723, appium:reboot: false, appium:relaxedSecurityEnabled: true, appium:robotAddress: 0.0.0.0, appium:robotPort: -1, appium:safari: false, appium:sessionOverride: false, appium:shell: false, appium:showConfig: false, appium:showIOSLog: false, appium:skipUninstall: true, appium:suppressKillServer: false, appium:testName: Flutter Automation, appium:tmpDir: C:UsersNMAHES~1AppDataL…, appium:useKeystore: false, appium:wdaLocalPort: 8100, appium:webkitDebugProxyPort: 27753, platformName: ANDROID}
Element: [io.github.ashwith.flutter.FlutterElement@8343364 -> unknown locator]
Session ID: f457e47b-31f2-4c5c-af08-1f94839dbe02
txt_username is valid locator but i am getting unknown locator [io.github.ashwith.flutter.FlutterElement@6cfedde -> unknown locator]
for txt_password is not a valid locator but I am getting [io.github.ashwith.flutter.FlutterElement@8343364 -> unknown locator]

Pom.xml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.test</groupId>
<artifactId>PracticeTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PracticeTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.6.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>io.github.ashwithpoojary98</groupId>
<artifactId>appium_flutterfinder_java</artifactId>
<version>1.0.5</version>
</dependency>
</dependencies>
</project>
</code>
<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.demo.test</groupId> <artifactId>PracticeTest</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>PracticeTest</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>8.6.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.12.0</version> </dependency> <dependency> <groupId>io.github.ashwithpoojary98</groupId> <artifactId>appium_flutterfinder_java</artifactId> <version>1.0.5</version> </dependency> </dependencies> </project> </code>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.demo.test</groupId>
    <artifactId>PracticeTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>PracticeTest</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>8.6.0</version>
        </dependency>
        
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.12.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.ashwithpoojary98</groupId>
            <artifactId>appium_flutterfinder_java</artifactId>
            <version>1.0.5</version>
        </dependency>


    </dependencies>
</project>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật