ashwithpoojary98 / javaflutterfinder

Flutter driver with Java implementation
MIT License
10 stars 5 forks source link

I am trying to automate flutter app using java and flutter finder. For each and every flutter element I am getting unknown locator #21

Open Maheshbabu78 opened 3 days ago

Maheshbabu78 commented 3 days ago

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("http://127.0.0.1:4723/wd/hub"), flutterCapabilities);
    System.out.println("Created AppiumDriver");
}

@Test
public void checkLoginFunction() throws InterruptedException {

    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("user@gmail.com");
    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: [17c020f7-d872-458b-9e49-0a5991d7a1c5, sendKeysToElement [id, value]] Capabilities {appium:address: 127.0.0.1, appium:allowCors: false, appium:allowInsecure: [], appium:androidCoverage: false, appium:app: C:\Users\NMAHESHBABU\flutte..., 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:\Users\NMAHESHBABU.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:\Users\NMAHES~1\AppData\L..., appium:useKeystore: false, appium:wdaLocalPort: 8100, appium:webkitDebugProxyPort: 27753, platformName: ANDROID} Element: [io.github.ashwith.flutter.FlutterElement@8343364 -> unknown locator] Session ID: 17c020f7-d872-458b-9e49-0a5991d7a1c5

txt_username is valid locator but i am getting [io.github.ashwith.flutter.FlutterElement@6cfedde -> unknown locator] unknown locator txt_pass is wring locator but i am getting [io.github.ashwith.flutter.FlutterElement@8343364 -> unknown locator] same. How can we identify element is present on the mobile page or not if we perform an action it is taking 2 minutes time to terminate

![Uploading Screenshot 2024-06-27 102705.png…]()

ashwithpoojary98 commented 2 days ago

@Maheshbabu78 I haven't encountered this case before. I'll update you once the issue is fixed