tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_get_computed_label.py (1001B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 from urllib.parse import quote
      6 
      7 from marionette_driver import By, errors
      8 from marionette_harness import MarionetteTestCase
      9 
     10 
     11 def inline(doc):
     12    return "data:text/html;charset=utf-8,{}".format(quote(doc))
     13 
     14 
     15 class TestGetComputedLabel(MarionetteTestCase):
     16    def test_can_get_computed_label(self):
     17        self.marionette.navigate(inline("<label for=b>foo<label><input id=b>"))
     18        computed_label = self.marionette.find_element(By.ID, "b").computed_label
     19        self.assertEqual(computed_label, "foo")
     20 
     21    def test_get_computed_label_no_such_element(self):
     22        self.marionette.navigate(inline("<div id=a>"))
     23        element = self.marionette.find_element(By.ID, "a")
     24        element.id = "b"
     25        with self.assertRaises(errors.NoSuchElementException):
     26            element.computed_label