AppiumTestDistribution / appium-flutter-integration-driver

MIT License
32 stars 10 forks source link

Swich context : Flutter and Native app #78

Closed thuonglai closed 3 months ago

thuonglai commented 3 months ago

Hi @saikrishna321 . When i change context from flutter to native app as the following code


WebElement inputPhoneNumber = androidDriver().findElement(FlutterBy.key(registrationPhoneField));
        waitForVisible(inputPhoneNumber);
        inputPhoneNumber.sendKeys(mobileNumber);

String otpXpath = "//*[@class='android.widget.EditText']";
        WebElement element = androidDriver().findElement(AppiumBy.xpath(otpXpath));
        element.clear();
      element.sendKeys(otp);

It happen error "org.openqa.selenium.InvalidArgumentException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 10 path $.text " in line element.sendKeys(otp);

Please guide me how to change context between flutter and native app. Thanks

saikrishna321 commented 3 months ago

@thuonglai please share full server logs and also device logs as gist

vudiuht commented 3 months ago

hi @saikrishna321, FlutterBy is for FLUTTER context and NATIVEAPP and WEBVIEW don't have example to know which context we are in? When using Flutter Driver we should call: androidDriver().context("NATIVE_APP"); to switch to NATIVE_APP context. androidDriver().context("WEBVIEW"); to switch to WEBVIEW context androidDriver().context("FLUTTER"); to switch to FLUTTER context.

saikrishna321 commented 3 months ago

@vudiuht u dont need any switching, FlutterBy is for flutter and AppiumBy is for native UIA2

github-actions[bot] commented 3 months ago

:tada: This issue has been resolved in version 1.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: