Closed Bug 1094246 Opened 10 years ago Closed 7 years ago

Marionette's isElementDisplayed atom thinks XUL elements in the about:* pages are not visible

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(firefox58 fixed)

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: chmanchester, Assigned: whimboo)

References

Details

(Keywords: pi-marionette-displayed, Whiteboard: [affects=loop])

I'm trying to convert a test case that clicks the "Open a Private Window" button in "about:privatebrowsing". I can select the button from the content scope with a selector ("button.openPrivate") and get an element back, but the click fails with an ElementNotVisible exception. From chrome scope I try to select the button but get 
"JavascriptException: No such strategy". I guess the visibility check isn't applicable for xul elements, and finding elements with a selector doesn't really make sense in chrome scope, so we have a catch 22.
I actually just noticed the same thing with "send_keys" in about:preferences. The second part of your problem (no such strategy) is because "css selector" isn't supported in chrome scope for some reason, I filed bug 1094441 to enable it.
(In reply to Andrew Halberstadt [:ahal] from comment #1)
> I actually just noticed the same thing with "send_keys" in
> about:preferences. The second part of your problem (no such strategy) is
> because "css selector" isn't supported in chrome scope for some reason, I
> filed bug 1094441 to enable it.

Cool, thanks Andrew! I guess this might still be an issue if about: pages are in the content process.
FYI: Nearly all of the about: pages are in-content XUL documents.
I think Chris is looking into something else, I'll investigate.
Assignee: nobody → ahalberstadt
Status: NEW → ASSIGNED
The webdriver isDisplayed atom is returning false. Because marionette uses a minified version, I'm unable to step through it but I think the function that ultimately is being called is:
https://code.google.com/p/selenium/source/browse/javascript/atoms/dom.js#557

That's a relatively complicated function, so I'm not sure where along there false is being returned. Because this is xul, I'm not even sure that fixing it upstream is desirable. Maybe we just need to detect whether we're dealing with a xul element and write our own isDisplayed function for it instead of invoking the webdriver atom.

David, do you know if..

1) It's possible to make marionette use the non-minimized atoms so I can step through it with the debugger?
2) This should be fixed in upstream webdriver or not?
Flags: needinfo?(dburns)
FWIW, removing the visibility check here makes everything work:
http://dxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-listener.js#1426

I'll come up with a patch that fixes things on our side while we decide what to do with the upstream function.
Summary: Can't click a xul element in a html page → Marionette's isElementDisplayed atom thinks XUL elements in the about:* pages are not visible
(In reply to Andrew Halberstadt [:ahal] from comment #5)
> The webdriver isDisplayed atom is returning false. Because marionette uses a
> minified version, I'm unable to step through it but I think the function
> that ultimately is being called is:
> https://code.google.com/p/selenium/source/browse/javascript/atoms/dom.js#557
> 
> That's a relatively complicated function, so I'm not sure where along there
> false is being returned. Because this is xul, I'm not even sure that fixing
> it upstream is desirable. Maybe we just need to detect whether we're dealing
> with a xul element and write our own isDisplayed function for it instead of
> invoking the webdriver atom.
> 
> David, do you know if..
> 
> 1) It's possible to make marionette use the non-minimized atoms so I can
> step through it with the debugger?

I see that jleyba answered your question

> 2) This should be fixed in upstream webdriver or not?

We could upstream this but it would need to be behind firefox specific conditionals on the atom.



You can also do |./go clean debug-server| and then visit http://localhost:2310/javascript/atoms/test/file_with_xul_test.html

I suspect the issue is that we may need to write this from scratch for XUL because XUL.

ato has rewritten this part of the spec recently (https://github.com/w3c/webdriver/pull/4) and we could have a look at implementing it from scratch
Flags: needinfo?(dburns)
I decided to throw in the towel with regards to figuring out exactly where in isShown() the problem is happening. AutomatedTester thinks we'll basically re-implement it from scratch for XUL elements, so I think for now we should just not call into the Webdriver implementation if we're dealing with XUL.

I filed bug 1096571 to track that change. This bug will remain about solving the issue properly (either by fixing upstream webdriver or implementing our own XUL specific method).
No longer blocks: m21s
No longer blocks: 1096488
Assignee: ahalberstadt → nobody
Status: ASSIGNED → NEW
Possibly the element visibility algorithm should have an explicit type check that the given input is a DOMNode.
Whiteboard: [affe
Whiteboard: [affe → [affects=loop]
A great temporary measure would be to have element.is_displayed() return an NotYetImplemented bug, ideally with a pointer to a link describing how to work around it.  This would at least prevent people from sinking a lot of time into debugging something that it appears that it ought to work.
(In reply to Dan Mosedale (:dmose) - needinfo? me for response from comment #11)
> A great temporary measure would be to have element.is_displayed() return an
> NotYetImplemented bug, ideally with a pointer to a link describing how to
> work around it.  This would at least prevent people from sinking a lot of
> time into debugging something that it appears that it ought to work.

There's no such error code in WebDriver as far as I'm aware, but we could use a generic error with a custom message.  I think it's a good idea to avoid confusion.

(In reply to Andrew Halberstadt [:ahal] from comment #5) 
> 1) It's possible to make marionette use the non-minimized atoms so I can
> step through it with the debugger?

I looked into upgrading the atoms about a year ago or so with no success.  Admittedly I didn't try very hard, but the way the atoms have been generated and exported for Marionette is not documented anywhere.  This means it's actually quite hard to figure out exactly which atoms are used in Marionette.

However, upgrading the atoms seems like it could be a separate bug.  I think the earlier suggestion to special case content XUL documents could make sense for the time being, or at least returning an error until we come up with something better.
FTR the change to special case content XUL landed awhile ago in bug 1096571:
https://dxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-listener.js#841

I guess there's a code path that bypasses that check that the loop team must have hit?
(In reply to Andreas Tolfsen (:ato) from comment #12)
> (In reply to Dan Mosedale (:dmose) - needinfo? me for response from comment
> #11)
> > A great temporary measure would be to have element.is_displayed() return an
> > NotYetImplemented bug, ideally with a pointer to a link describing how to
> > work around it.  This would at least prevent people from sinking a lot of
> > time into debugging something that it appears that it ought to work.
> 
> There's no such error code in WebDriver as far as I'm aware, but we could
> use a generic error with a custom message.  I think it's a good idea to
> avoid confusion.

That would be wonderful.  Right now, the failure mode is that the wait simply times out, leaving the programmer to think that the element isn't being displayed.

For a custom message, how about something like "element.is_displayed() is not yet implemented for XUL/XBL elements; consider using marionette.find_element() as a workaround".

Is there any chance this could be done relatively soon to avoid devs sinking a lot of time following the wrong path?
Flags: needinfo?(ato)
(In reply to Dan Mosedale (:dmose) - needinfo? me for response from comment #14)
> (In reply to Andreas Tolfsen (:ato) from comment #12)
> > (In reply to Dan Mosedale (:dmose) - needinfo? me for response from comment
> > #11)
> > > A great temporary measure would be to have element.is_displayed() return an
> > > NotYetImplemented bug, ideally with a pointer to a link describing how to
> > > work around it.  This would at least prevent people from sinking a lot of
> > > time into debugging something that it appears that it ought to work.
> > 
> > There's no such error code in WebDriver as far as I'm aware, but we could
> > use a generic error with a custom message.  I think it's a good idea to
> > avoid confusion.
> 
> That would be wonderful.  Right now, the failure mode is that the wait
> simply times out, leaving the programmer to think that the element isn't
> being displayed.
> 
> For a custom message, how about something like "element.is_displayed() is
> not yet implemented for XUL/XBL elements; consider using
> marionette.find_element() as a workaround".
> 
> Is there any chance this could be done relatively soon to avoid devs sinking
> a lot of time following the wrong path?

Just to clarify: Should all calls to to isElementDisplayed in chrome context return with an error, or just calling that on elements in about:* documents?
Flags: needinfo?(ato) → needinfo?(dmose)
Everywhere, for the main reason that it does the wrong thing in (presumably?) all chrome contexts, which currently leaves any developer using Marionette for chrome testing vulnerable to wasting a bunch of time debugging the wrong thing.

We're certainly seeing the problem in normal chrome context, on an element which only contains an about: URL in an internal iframe down inside the XBL.
Flags: needinfo?(dmose)
I believe this is affecting my ability to wait for a popup notification (door hanger) to be displayed when attempting to install an add-on from https://addons.mozilla.org/. Is there an update or workaround, short of having lots of hard-coded sleeps?
Flags: needinfo?(ato)
(In reply to Dave Hunt (:davehunt) from comment #17)
> I believe this is affecting my ability to wait for a popup notification
> (door hanger) to be displayed when attempting to install an add-on from
> https://addons.mozilla.org/. Is there an update or workaround, short of
> having lots of hard-coded sleeps?

Unfortunately we are not working on Chrome stuff as a priority as we need to have better parity with webdriver first. I don't know of a workaround currently.
Flags: needinfo?(ato)
If the XUL element supports elementsFromPoint you might be able to use element.isPointerInteractable that I implemented some time ago: https://github.com/mozilla/gecko-dev/blob/master/testing/marionette/element.js#L866

You will unfortunately have to hack Marionette a bit to expose it, but it would be very interesting to hear if that works for you!
I have ran into this bug wanting to test about:addons. Has there been a change that could make this possible, or is the information within this bug still worth following.
Flags: needinfo?(ato)
(In reply to Benjamin Forehand Jr[:b4hand] from comment #20)

> I have ran into this bug wanting to test about:addons. Has there
> been a change that could make this possible, or is the information
> within this bug still worth following.

https://bugzil.la/1321516 tracks enabling the WebDriver-conforming
click implementation by default.  Since then we have exposed a
"moz:webdriverClick" capability that lets you enable it from the
client.

However, I realise when re-reading my last comment that the new
click implementation will only work for DOM elements.  If the
element you’re interacting with is a XUL namespaced element you
will still see the same error.
Flags: needinfo?(ato)
I just tested this issue while working on bug 1414322, and it is no longer a problem. Looks like the update of the Selenium atoms as done via bug 1375660 made it work.

I will add a new testcase for that report with my patch on bug 1414322.
Assignee: nobody → hskupin
Status: NEW → RESOLVED
Closed: 7 years ago
Depends on: 1375660
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.