Closed Bug 938061 Opened 11 years ago Closed 11 years ago

Write a test to open Settings app from Utility tray

Categories

(Firefox OS Graveyard :: Gaia::UI Tests, defect)

Other
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(b2g-v1.2 affected)

RESOLVED FIXED
Tracking Status
b2g-v1.2 --- affected

People

(Reporter: zcampbell, Assigned: jhammink)

References

Details

Attachments

(2 files, 7 obsolete files)

Testcase

test setup:
none should be req'd

1. Open utility tray
2. Tap 'Settings' button
3. Wait for and assert the Settings app to be the displayed app.

This test can be enabled for TBPL, Travis and device testing in the respective manifests.
Are there other utility tray tests that can be used as a reference?
aha, ok:

test_system_notification_bar.py

lines 28 - 30:

        utility_tray = system.open_utility_tray()

        utility_tray.wait_for_notification_container_displayed()

mhmyes...
Yes I think for this test, aside from tapping the button itself, you can mostly get away with cannibalizing other tests for working code snippets :)
On a more basic note, is there a way to list available buttons or actionable DOM elements in the current context?  

https://marionette_client.readthedocs.org/en/latest/index.html#dom-element-methods offers some clues but I'm not quite there yet.  

In previous automation frameworks I've used, there have been tools to browse the object hierarchy.
The closest we have for that, I think, is the AppManager, which is available in Aurora and Nightly and was demoed at the Summit. It actually works quite well for inspecting the DOM, although it doesn't provide an actual list of actionable DOM elements.  Bebe wrote up some excellent instructions for using it. If you don't have those perhaps you can ping him for a copy.
Thanks for giving me the time to work on this!  Shoutout to all those who want to take this test from me - please don't!  I need to ramp up on this to learn.  Thank you.
I've emailed Bebe - asking for those instructions.  Bebe, if you could send those along, it would be really helpful!
Actually the instructions in "Help" (MDN) are pretty good already!
Are they?  I can't find very much on APIs and methods there.
I guess the assumption is that there is some expertise in Selenium required.  Still I wish that methods, etc were more discoverable.   This is hard going.
ok, I may need some help on the last bit.     

I can't seem to find the right thing to wait for to show that settings app is in focus.

I've browsed the DOM for settings app using app manager but most of those strings are localized so I don't know what to search for to wait.

Can someone have a look?
Attached file test_quick_settings.py (obsolete) —
Flags: needinfo?(bob.silverberg)
figured out what to wait for, but the assert is wrong.  Attaching latest version.  CCing Raymond, who helped me on the last step.
Attached file test_quick_settings.py (obsolete) —
Attachment #8337150 - Attachment is obsolete: true
Flags: needinfo?(bob.silverberg) → needinfo?(mozbugs.retornam)
Comment on attachment 8337170 [details]
test_quick_settings.py


>        #tap the settings button
>        self.marionette.find_element("id", "quick-settings-full-app").tap()

You will want to put this into the utility_tray.py app as a method and include the locator in it too.
tap_settings_button() or however you choose to name it.

>        
>        #wait for settings app to launch

Here we are switching apps so things get a bit tricky inside b2g but from the test side we are only interested in the Settings app coming to the top frame so the user can then use it.

We use this type of wait:
self.wait_for_condition(lambda m: self.apps.displayed_app.name == "Settings")

This makes sure that the Settings app is definitely the one which has come to the fore.

that is pretty much it for this test!
Flags: needinfo?(mozbugs.retornam)
So I've updated my test script to include the last wait.  I've attached it for posterity :)

Still need to figure out this next part:

>        #tap the settings button
>        self.marionette.find_element("id", "quick-settings-full-app").tap()

You will want to put this into the utility_tray.py app as a method and include the locator in it too.
tap_settings_button() or however you choose to name it.
Can you please show me an example of how this is done?
Understood that https://github.com/mozilla-b2g/gaia/blob/v1.2/tests/python/gaia-ui-tests/gaiatest/apps/system/regions/utility_tray.py?source=cc

Is the file to be changed, and I think you mean something needs to be changed in the first section, but I'm unclear as to what specifically.   Please understand I'm new to Selenium.
Flags: needinfo?(zcampbell)
Attached file test_quick_settings.py (obsolete) —
Attachment #8337170 - Attachment is obsolete: true
Attached file test_quick_settings.py (obsolete) —
Attachment #8338140 - Attachment is obsolete: true
Attached file utility_tray.py (obsolete) —
Ok, if no one minds, I'd like to attach these files here for review.  I think I did it right.  I know this isn't the "right" way to do this, but I want to make sure I know what I'm doing before we go back and forth on the pull requests.  Thanks.
John, that's exactly it! I haven't run it but it looks right.

The only nit I have is that settings_heading is no longer used in the test file so you can remove that.

When you create your pull request, also add the file into tests/functional/settings/manifest.ini (note these are all in alphabetical order) as this will tell the test runner to run it on device/desktop. No special tags (eg wifi) are needed for this test.
Flags: needinfo?(zcampbell)
Ok, I've removed that line from the testcase and checked it.  It works!  I'll need to check it still against 1.3 first.   I'll go through the steps and get the pull request going today or tomorrow.
Attached file test_quick_settings.py (obsolete) —
By the way, should we be writing tests against 1.3 at this point or is 1.2 still ok?
Looking good John.

We mostly write tests against v1.3 and then uplift it into v1.2 to closely follow the general Gaia workflow. Most tests work on both branches, though and I would be surprised if this is different.

If you could make the pull request against 1.3 (master) branch that would be ideal.
Ok, learning - and working on it - now.
Attachment #8339550 - Flags: review?(zcampbell)
isn't it supposed to add a link to the pull request here?   Ugg, confusing.
So I noticed on the pull request link that the travis build failed.  What happened?
Need-infoing Zac.  Not sure if this is necessary to get on your radar (possibly not) but wanted to resolve whatever the issue is in travis.
Flags: needinfo?(zcampbell)
...and actually learn what the issue is so I can fix it in the future.
Actually your test passed fine! I can see it on Travis at the bottom here:
https://travis-ci.org/mozilla-b2g/gaia/jobs/14628383

That means it's all fine.

There are some small tweaks to do to the code syntax but I'll note them in the pull request.
Flags: needinfo?(zcampbell)
I've finished the comments in the pull request John.

Functionally it's fine; the comments are just around style and layout to fit the standard of the rest of the test code.

Cheers!
Comment on attachment 8339550 [details] [review]
pointer to github pull request for 938061

r-, nitpick on syntax but functionally Ok.

re-set the r? when you have updated it!

Also,if you can, make the changes all in one commit so it is easier for the sheriffs and us to manage.
Attachment #8339550 - Flags: review?(zcampbell) → review-
Reset what r, where?

The pull request is updated, Zac.  I had some trouble squashing commits.  Please let me know if everything is OK.
Attachment #8339550 - Flags: review- → review?(zcampbell)
I should mention that I was unable to run tests after updating my pull request.

File "/usr/local/bin/gaiatest", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.macosx-10.7-intel/egg/pkg_resources.py", line 2793, in <module>
    
  File "build/bdist.macosx-10.7-intel/egg/pkg_resources.py", line 673, in require
    def subscribe(self, callback):
  File "build/bdist.macosx-10.7-intel/egg/pkg_resources.py", line 576, in resolve
    plugin_env, full_env=None, installer=None, fallback=True
pkg_resources.DistributionNotFound: gaiatest==0.18

I know it's not my changes because I did a second clone of gaia and ran a different test that worked before, and still saw the issue.
Ok, Bob Silverberg helped me get set up with virtualenv again, so my tests are again running with gaiatests 0.19.  Thank you Bob!

Another problem has popped up when I run the test:

TEST-UNEXPECTED-FAIL | test_quick_settings.py test_quick_settings.TestQuickSettingsButton.test_quick_settings_button | AttributeError: 'UtilityTray' object has no attribute 'tap_settings_button'


But file apps/system/regions/utility_tray.py has such a method:

    def tap_settings_button(self):
    	self.marionette.find_element(*self._quicksettings_app_locator).tap()

which points to this locator:  

  _quicksettings_app_locator = (By.ID, 'quick-settings-full-app')

So not sure what happened there, unless the ID suddenly changed in yesterday's gaia build.   I'll break out the app damager tomorrow and eyeball this, but maybe there is something else happening?
OK, squashed everything to one commit (I think) and the test is working again.  Let's get this in!
Attachment #8339550 - Flags: review?(zcampbell) → review?(bob.silverberg)
Comment on attachment 8339550 [details] [review]
pointer to github pull request for 938061

r+ assuming the code formatting issues get fixed
Attachment #8339550 - Flags: review?(bob.silverberg) → review+
Comment on attachment 8339550 [details] [review]
pointer to github pull request for 938061

https://github.com/mozilla-b2g/gaia/pull/14378
Comment on attachment 8339550 [details] [review]
pointer to github pull request for 938061

https://github.com/mozilla-b2g/gaia/pull/14378
Attachment #8339550 - Flags: review+ → review?(bob.silverberg)
Comment on attachment 8339550 [details] [review]
pointer to github pull request for 938061

https://github.com/mozilla-b2g/gaia/pull/14378
Attached file latest pull request
pull request: https://github.com/mozilla-b2g/gaia/pull/14378
Attachment #8338150 - Attachment is obsolete: true
Attachment #8338152 - Attachment is obsolete: true
Attachment #8338843 - Attachment is obsolete: true
Attachment #8339550 - Attachment is obsolete: true
Attachment #8339550 - Flags: review?(bob.silverberg)
Attachment #8342722 - Flags: review?(bob.silverberg)
Comment on attachment 8342722 [details] [review]
latest pull request

Landed on master in https://github.com/mozilla-b2g/gaia/commit/d2471af1a99a193107c539950ce965663d0b765c
Attachment #8342722 - Flags: review?(bob.silverberg) → review+
This should be uplifted to v1.2 as well.
Attachment #8343745 - Flags: review?(florin.strugariu)
Attachment #8343745 - Flags: review?(bob.silverberg)
Attachment #8343745 - Flags: review?(florin.strugariu) → review+
Comment on attachment 8343745 [details]
Pointer to Github pull request: https://github.com/mozilla-b2g/gaia/pull/14464

Let's merge it when the tree opens.
Attachment #8343745 - Flags: review?(bob.silverberg) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: