How to get one of the elements if the finder matched more than one?
See original GitHub issueWith the finder from appium-flutter-driver, sometimes I got more than one element returned. Then if I do another API call, it returns Bad state: Too many elements
. For example, in the code below, if there are more than one widgets with the same text:
from appium_flutter_finder import FlutterElement, FlutterFinder
finder = FlutterFinder()
text_finder = finder.by_text(text)
element = FlutterElement(driver, text_finder)
print(element.text)
the last line will raise:
(<class 'selenium.common.exceptions.WebDriverException'>, WebDriverException('An unknown server-side error occurred while processing the command. Original error: Cannot execute command get_text, server reponse {\n "isError": true,\n "response": "Uncaught extension error while executing get_text: Bad state: Too many elements\\n#0 Iterable.single (dart:core/iterable.dart:560)\\n#1 FlutterDriverExtension._getText (package:flutter_driver/src/extension/extension.dart:625)\\n<asynchronous suspension>\\n#2 FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:273)\\n<asynchronous suspension>\\n#3 BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:547)\\n<asynchronous suspension>\\n",\n "type": "_extensionType",\n "method": "ext.flutter.driver"\n}', None, None), <traceback object at 0x102059180>)
If I call element[0].text
, I will get (<class 'TypeError'>, TypeError("'FlutterElement' object is not subscriptable"), <traceback object at 0x10d001600>)
.
So my question is, how can I get one of the elements if the finder matched several widgets? Any help is appreciated. 🙏
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to get one of the elements if the finder matched ... - GitHub
With the finder from appium-flutter-driver, sometimes I got more than one element returned. Then if I do another API call, it returns Bad ......
Read more >Keep only one element of each group of elements who match ...
The pythonic way is to rename your match method to __eq__ . Then you can do things like element in list with your...
Read more >Regular Expressions in A Better Finder Select - publicspace.net
If the RE could match more than one substring starting at that point, its choice is determined by its preference: either the longest...
Read more >Finders - Kofax Product Documentation
To include an element in the finder evaluation, right-click an element and select Include Cell When Finding. To exclude an element, right-click a...
Read more >ElementArrayFinder - Protractor
Count the number of elements represented by the ElementArrayFinder. isPresent, Returns true if there are any elements present that match the finder. locator ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hex0cter I’m also looking for a solution to the same issue.
Perhaps currently this is a flutter (or flutter_driver by Flutter team) limitation.