testing/firefox-ui/tests/puppeteer/test_menubar.py
author Nicholas Nethercote <nnethercote@mozilla.com>
Wed, 27 Apr 2016 14:16:50 +1000
changeset 336387 3d67e45f994a3ae1ae43479c32c2ed63bbf1a7c8
parent 329944 7e807a003ea4c3a4680f2f0c7bbab8883a1a4db7
child 352958 791641aca0f80086370d707dcc897cd6449eccf9
permissions -rw-r--r--
Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. It's an annotation that is used a lot, and should be used even more, so a shorter name is better. MozReview-Commit-ID: 1VS4Dney4WX

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_driver.errors import NoSuchElementException

from firefox_ui_harness.testcases import FirefoxTestCase


class TestMenuBar(FirefoxTestCase):

    def setUp(self):
        FirefoxTestCase.setUp(self)

    def test_click_item_in_menubar(self):
        num_tabs = len(self.browser.tabbar.tabs)

        def opener(_):
            self.browser.menubar.select_by_id('file-menu',
                                              'menu_newNavigatorTab')

        self.browser.tabbar.open_tab(trigger=opener)

        self.browser.tabbar.tabs[-1].close()

    def test_click_non_existent_menu_and_item(self):
        with self.assertRaises(NoSuchElementException):
            self.browser.menubar.select_by_id('foobar-menu',
                                              'menu_newNavigatorTab')

        with self.assertRaises(NoSuchElementException):
            self.browser.menubar.select_by_id('file-menu', 'menu_foobar')