UnexpectedAlertPresentException when attempting to use Browser Toolbox

NEW
Unassigned

Status

Testing
Marionette
P3
normal
5 months ago
2 months ago

People

(Reporter: davehunt, Unassigned)

Tracking

Version 3
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 months ago
It can be useful to interrupt a running instance of Firefox w/ Marionette by opening the Browser Toolbox to inspect elements in chrome. I noticed whilst demonstrating this last week that Marionette is throwing UnexpectedAlertPresentException even after the prompt to enable remote debugging is dismissed.

Steps to replicate (using Python with selenium 3.4.3 installed):

1. Run the following in a Python interactive shell:

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
options = Options()
options.set_preference('devtools.chrome.enabled', True)
options.set_preference('devtools.debugger.remote-enabled', True)
options.binary = '/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin'
firefox = Firefox(firefox_options=options)
firefox.get('http://example.com')

2. Open Browser Toolbox from Firefox, and accept prompt when displayed.

3. Running any command such as firefox.refresh() will raise an UnexpectedAlertPresentException.

I'm able to switch to the alert using firefox.switch_to_alert(), however the returned Alert object raises NoAlertPresentException when calling any of its methods or properties.
(Reporter)

Comment 1

5 months ago
It seems to work fine if I accept the remote connection prompt using firefox.switch_to_alert().accept() rather than doing it by clicking the button. Perhaps dismissing/accepting the alert manually is not clearing the alert detected by Marionette?
Nothing in the spec talks about a real click, so I would assume you would have to use the provided commands:

https://w3c.github.io/webdriver/webdriver-spec.html#dfn-dismiss

Andreas, or David?
(In reply to Dave Hunt (:davehunt) from comment #0)

> It can be useful to interrupt a running instance of Firefox w/
> Marionette by opening the Browser Toolbox to inspect elements in
> chrome. I noticed whilst demonstrating this last week that Marionette
> is throwing UnexpectedAlertPresentException even after the prompt to
> enable remote debugging is dismissed.

This is because the dialogue is a global dialogue that is detected by
Marionette.  My suspicion is that this only happens when you interrupt
an IPC message to the content frame script.

> from selenium.webdriver import Firefox
> from selenium.webdriver.firefox.options import Options
> options = Options()
> options.set_preference('devtools.chrome.enabled', True)
> options.set_preference('devtools.debugger.remote-enabled', True)

You may want to try setting marionette.debugging.clicktostart, which is
what --js-debugger uses.
(Reporter)

Comment 4

5 months ago
> You may want to try setting marionette.debugging.clicktostart, which is what --js-debugger uses.

This just seems to cause a modal dialog in Firefox, which I assume you're suggesting I open the Browser Toolbox before accepting, but I'm unable to do so.
Flags: needinfo?(ato)
(In reply to Dave Hunt (:davehunt) from comment #1)

> It seems to work fine if I accept the remote connection prompt using
> firefox.switch_to_alert().accept() rather than doing it by clicking
> the button. Perhaps dismissing/accepting the alert manually is not
> clearing the alert detected by Marionette?

Our user prompt implementation isn’t great, so this is likely a bug to
do with tracking them.  My guess is that it thinks the prompt is still
there after you click to dismiss it.
Flags: needinfo?(ato)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.