XPath queries with quotes or spaces in values don't work

Bug #1179806 reported by I Ahmad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Autopilot
Fix Released
High
Unassigned
XPathSelect
Fix Released
Low
Unassigned

Bug Description

autopilot-gtk 1.3 doesn't support the query like below

'/Root//GtkWindow/GtkMenu/GtkImageMenuItem[name=_Save As]'

This was supported in earlier versions of Autopilot/Autopilot-gtk.

Tags: has-testcase

Related branches

I Ahmad (iahmad)
description: updated
Revision history for this message
Martin Pitt (pitti) wrote :

This is rather vague, but I assume you are using the self.app.get_state_by_path() method to retrieve the raw D-BUS state array for an XPath? Further, this works in general (I'm currently writing test cases for this), but I can confirm that queries don't work which involve spaces in the property values. In XPath it is supposed to work with

 "/Root//GtkWindow/GtkMenu/GtkImageMenuItem[name='_Save As']"

but it doesn't.

Changed in autopilot-gtk:
status: New → Triaged
summary: - Autopilot-gtk 1.3 doesn't return filtered results.
+ XPath queries with spaces in values don't work
Revision history for this message
Martin Pitt (pitti) wrote : Re: XPath queries with spaces in values don't work

Retitling bug accordingly. Please confirm that this is what you are seeing.

Revision history for this message
Martin Pitt (pitti) wrote :

Reproduced in test case: http://bazaar.launchpad.net/~pitti/autopilot-gtk/add-tests/revision/60

This also adds some other tests which confirm that XPath queries are working in general.

Martin Pitt (pitti)
summary: - XPath queries with spaces in values don't work
+ XPath queries with quotes or spaces in values don't work
Revision history for this message
Martin Pitt (pitti) wrote :

This is a bug in xpathselect. There is no way to quote a space, like with   or   or by quoting the attribute value.

Also, quotes themselves don't work in xpathselect. I attach a patch which adds two test cases, one for a quoted value, and one for a quoted value with a space.

Please note that current xpathselect violates the xpath specification: an expression like "/Root//*[visible=True]" selects a <visible> child with a string contents "True". Nodes with an attribute with that value are selected with "/Root//*[@visible=True]" , but xpathselect currently doesn't seem to handle the @. (See http://www.w3.org/TR/xpath/#path-abbrev). Changing that would need an accompanying fix in autopilot, and I guess it's not that urgent. But regardless of that, quotes should work, so that one can select arbitrary attribute or node values.

Changed in autopilot-gtk:
assignee: Allan LeSage (allanlesage) → nobody
status: Triaged → Invalid
tags: added: has-testcase
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

This is a known issue in xpathselect. We have some tentative plans to fix it. However, we can work around this in autopilot in the mean time.

Martin: note that xpathsleect is not intended to implement the w3c xpath spec. Rather, it is "inspired by" xpathselect.

In the future, I plan to make the query language typed, so we can have proper quoted strings. Until then... lets work around this in autopilot.

Changed in xpathselect:
status: New → Confirmed
importance: Undecided → Low
Changed in autopilot:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:xpathselect at revision 38, scheduled for release in xpathselect, milestone 1.3

Changed in xpathselect:
status: Confirmed → Fix Committed
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:autopilot at revision 325, scheduled for release in autopilot, milestone 1.4

Changed in autopilot:
status: Confirmed → Fix Committed
Changed in autopilot:
milestone: none → 1.4
Changed in autopilot:
status: Fix Committed → Fix Released
Changed in xpathselect:
status: Fix Committed → Fix Released
no longer affects: autopilot-gtk
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.