Skip to content

Get value from text widget with semantic lable #440

Open
@Takrem1

Description

@Takrem1

Hey

I want to use Appium under Python with the Appium Flutter driver to test my Flutter application. Some things are already working, but I have a problem with the text widgets.

I can locate a text element using the semanticsLable (see code), but then it is not possible to read the text value from the FlutterElement. Am I doing something wrong here or does it just not work this way?

Flutter code:

const Text("Text with semanticsLable", semanticsLabel: "text_semantic_lable"),

Python code:

driver = Remote('http://127.0.0.1:4723',
                {'platformName': 'android',
                 'automationName': 'flutter',
                 'platformVersion': '',
                 'deviceName': 'emulator-5554',
                 'app': '/Users/xxxx/AndroidStudioProjects/hello_world_appium/build/app/outputs/flutter-apk/app-debug.apk'
                 })

finder = FlutterFinder()
text_finder = finder.by_semantics_label("text_semantic_lable")
text_element = FlutterElement(driver, text_finder)
print(text_element.text)

Error log:

Traceback (most recent call last):
  File "/Users/xxx/git/hmip-regression-testing/tests/hmip_tests/solutions/IC/flutter_test.py", line 90, in <module>
    print(text_element.text)
          ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 89, in text
    return self._execute(Command.GET_ELEMENT_TEXT)["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 403, in _execute
    return self._parent.execute(command, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.11/site-packages/appium/webdriver/errorhandler.py", line 30, in check_response
    raise wde
  File "/usr/local/lib/python3.11/site-packages/appium/webdriver/errorhandler.py", line 26, in check_response
    super().check_response(response)
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot execute command get_text, server reponse {
  "isError": true,
  "response": "Uncaught extension error while executing get_text: Unsupported operation: Type Semantics is currently not supported by getText\n#0      CommandHandlerFactory._getText (package:flutter_driver/src/common/handler_factory.dart:430:7)\n<asynchronous suspension>\n#1      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:372:31)\n<asynchronous suspension>\n#2      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:856:18)\n<asynchronous suspension>\n",
  "type": "_extensionType",
  "method": "ext.flutter.driver"
}
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot execute command get_text, server reponse {
  "isError": true,
  "response": "Uncaught extension error while executing get_text: Unsupported operation: Type Semantics is currently not supported by getText\n#0      CommandHandlerFactory._getText (package:flutter_driver/src/common/handler_factory.dart:430:7)\n<asynchronous suspension>\n#1      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:372:31)\n<asynchronous suspension>\n#2      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:856:18)\n<asynchronous suspension>\n",
  "type": "_extensionType",
  "method": "ext.flutter.driver"
}
    at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1067:9)
    at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:476:57)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions