Add method for dumping widget and its children to stdout
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Autopilot |
Fix Released
|
Wishlist
|
Martin Pitt | ||
autopilot (Ubuntu) |
Fix Released
|
Undecided
|
rosa maria |
Bug Description
When writing autopilot tests, finding the type and exact properties of the exact widget that I'm seeing somewhere on the screen is one of the biggest challenges. Many widgets can get an explicit identifier (objectName in QML or GtkBuilder ID in Gtk), but often this doesn't help: For example the actually visible labels in a QML list view are hidden many layers benath some unintelligible nested QtQuickItem, HandlerDelegate, and other bits, which makes finding anything in vis hard.
So I often temporarily add a snippet like
widgets = set()
self.
for c in widgets:
for p in c.get_properties():
print ' ', p, repr(getattr(c, p))
@classmethod
def _get_widgets(klass, obj, widget_set):
for c in obj.get_children():
to just dump a particular parent widget (like said list view) and recursively all of its children to stdout, where it's easy to find with grep or just by looking if there aren't too many children.
I'd like to add this to AP itself, with some prettyness: Proper indentation according to nesting level, output to a file name, and so on.
Related branches
- Thomi Richards (community): Approve
- PS Jenkins bot: Approve (continuous-integration)
-
Diff: 216 lines (+159/-1)3 files modifiedautopilot/introspection/dbus.py (+41/-0)
autopilot/tests/functional/test_introspection_features.py (+45/-1)
autopilot/tests/unit/test_introspection_features.py (+73/-0)
Changed in autopilot: | |
importance: | Undecided → Wishlist |
assignee: | nobody → Martin Pitt (pitti) |
Changed in autopilot: | |
milestone: | none → 1.4 |
status: | Fix Committed → Fix Released |
Changed in autopilot (Ubuntu): | |
assignee: | nobody → rosa maria (rprosamaria383) |
Should probably also limit the number of levels deep you go, but it sounds nice. Maybe allow the author to pass in a file-like object to write to, but default to sys.stdout?