How to get the elements inside a newly opened window?

41 views
Skip to first unread message

M.-A. DARCHE

unread,
Sep 6, 2010, 11:45:55 AM9/6/10
to mozmi...@googlegroups.com
Hello list,

I used to have modal dialogs for the extension I'm working on,
and I was thus using the ModalDialogAPI shared module for interacting
with those windows. But now I'm using non-modal dialogs since it is
recommended as it makes a better user experience.

That leads to the question: How to get the elements inside
a newly opened non-modal window?

The Mozmill "graphic recorder" suggests using the following code:
controller2 = new
mozmill.controller.MozMillController(mozmill.utils.getWindowByTitle("Fidesfit:
configuration"));

But it doesn't work and return the following error:
ERROR | Test Failure: {"exception": {"message": "controller(): Window
could not be initialized.", "lineNumber": 421, "stack":
"Error(\"controller(): Window could not be
initialized.\")@:0\nwaitFor((function () {return window != null &&
window.documentLoaded != undefined;}),5000,100,\"controller(): Window
could not be
initialized.\")@file:///tmp/tmpJ-qqyH.mozrunner/extensions/moz...@mozilla.com/resource/modules/utils.js:421\n((void
0))@file:///tmp/tmpJ-qqyH.mozrunner/extensions/moz...@mozilla.com/resource/modules/controller.js:152\n()@file:///tmp/tmpJ-qqyH.mozrunner/extensions/moz...@mozilla.com/resource/modules/frame.js
->
file:///home/firefox/fidesfi...@fidesfit.org/test/mozmill/tests/test_configure.js:82

I'm using mozmill 1.5.0

And here is a precedent email threading tackling the subject:
http://groups.google.com/group/mozmill-dev/browse_thread/thread/11a796825a2e6fe8


Could someone help me on this please?

PS: "utils.getWindowByTitle" is rightly present in the Mozmill code,
but not documented on https://developer.mozilla.org/


--
M.-A. DARCHE https://developer.mozilla.org/User:madarche
AFUL http://aful.org/
Association Francophone des Utilisateurs de Logiciels Libres
French speaking Libre Software Users' Association

Florian Aspart

unread,
Sep 6, 2010, 12:37:02 PM9/6/10
to MozMill Developers
Hi,
what is the name of your windows in the XUL code? If you can't access
the windows by it's name you can try to access it by its type :
"module.controller=new
mozmill.controller.MozMillController(mozmill.utils.getWindowByType("windows-
type"));"
Maybe you are trying to access the window before it is being
displayed.
Another possible cause of error would be that your window is still
modal, in which case the windows could not be accessed this way and
you would get exactly this error message actually...
Floria


On Sep 6, 5:45 pm, "M.-A. DARCHE" <moz...@cynode.org> wrote:
> Hello list,
>
> I used to have modal dialogs for the extension I'm working on,
> and I was thus using the ModalDialogAPI shared module for interacting
> with those windows. But now I'm using non-modal dialogs since it is
> recommended as it makes a better user experience.
>
> That leads to the question: How to get the elements inside
> a newly opened non-modal window?
>
> The Mozmill "graphic recorder" suggests using the following code:
> controller2 = new
> mozmill.controller.MozMillController(mozmill.utils.getWindowByTitle("Fidesfit:
> configuration"));
>
> But it doesn't work and return the following error:
> ERROR | Test Failure: {"exception": {"message": "controller(): Window
> could not be initialized.", "lineNumber": 421, "stack":
> "Error(\"controller(): Window could not be
> initialized.\")@:0\nwaitFor((function () {return window != null &&
> window.documentLoaded != undefined;}),5000,100,\"controller(): Window
> could not be
> initialized.\")@file:///tmp/tmpJ-qqyH.mozrunner/extensions/mozm...@mozilla.com/resource/modules/utils.js:421\n((void
> 0))@file:///tmp/tmpJ-qqyH.mozrunner/extensions/mozm...@mozilla.com/resource/modules/controller.js:152\n()@file:///tmp/tmpJ-qqyH.mozrunner/extensions/mozm...@mozilla.com/resource/modules/frame.js
> ->
> file:///home/firefox/fidesfit-cli...@fidesfit.org/test/mozmill/tests/test_configure.js:82
>
> I'm using mozmill  1.5.0
>
> And here is a precedent email threading tackling the subject:http://groups.google.com/group/mozmill-dev/browse_thread/thread/11a79...
>
> Could someone help me on this please?
>
> PS: "utils.getWindowByTitle" is rightly present in the Mozmill code,
> but not documented onhttps://developer.mozilla.org/

Henrik Skupin

unread,
Sep 6, 2010, 12:38:06 PM9/6/10
to mozmi...@googlegroups.com
M.-A. DARCHE wrote on 9/6/10 5:45 PM:

> That leads to the question: How to get the elements inside
> a newly opened non-modal window?

I would suggest that you should use the handleWindow function from utilsAPI:
http://hg.mozilla.org/qa/mozmill-tests/file/tip/shared-modules/testUtilsAPI.js#l361

--
Henrik Skupin
QA Execution Engineer
Mozilla Corporation

M.-A. DARCHE

unread,
Sep 6, 2010, 12:46:16 PM9/6/10
to mozmi...@googlegroups.com
Le 06.09.2010 18:38, Henrik Skupin a �crit :

> M.-A. DARCHE wrote on 9/6/10 5:45 PM:
>
>> That leads to the question: How to get the elements inside
>> a newly opened non-modal window?
>
> I would suggest that you should use the handleWindow function from utilsAPI:
> http://hg.mozilla.org/qa/mozmill-tests/file/tip/shared-modules/testUtilsAPI.js#l361
>

Thanks a lot Florian and Henrik.

I'll let the list know asap when it works,
and add the related documentation on the concerned pages on
https://developer.mozilla.org/

Cheers,

Nitin maliye

unread,
Sep 7, 2010, 2:14:33 AM9/7/10
to mozmi...@googlegroups.com
Hi,

You will be able to see 2 controllers inside your setup module please remove controller 2 from there.
Please use below code in testRecorded function.
let controller2 = new mozmill.controller.MozMillController(mozmill.utils.getWindowByTitle("Fidesfit:configuration"));
and then run the test.

Regards,
Nitin



--
You received this message because you are subscribed to the Google Groups "MozMill Developers" group.
To post to this group, send email to mozmi...@googlegroups.com.
To unsubscribe from this group, send email to mozmill-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mozmill-dev?hl=en.


Nitin maliye

unread,
Sep 7, 2010, 2:18:44 AM9/7/10
to mozmi...@googlegroups.com
In addition please make sure to add below code just after event called to open window "Fidesfit:configuration" (where controller 2 comes in picture).

M.-A. DARCHE

unread,
Sep 7, 2010, 10:45:10 AM9/7/10
to mozmi...@googlegroups.com
Le 06.09.2010 18:38, Henrik Skupin a �crit :
> M.-A. DARCHE wrote on 9/6/10 5:45 PM:
>
>> That leads to the question: How to get the elements inside
>> a newly opened non-modal window?
>
> I would suggest that you should use the handleWindow function from utilsAPI:
> http://hg.mozilla.org/qa/mozmill-tests/file/tip/shared-modules/testUtilsAPI.js#l361
>

This is the route I have chosen, because it includes a built-in wait for
the window to appear. And it works.

I'll document it ASAP

Thanks!

Reply all
Reply to author
Forward
0 new messages