test_get_computed_role.py (987B)
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 TestGetComputedRole(MarionetteTestCase): 16 def test_can_get_computed_role(self): 17 self.marionette.navigate(inline("<button id=a>btn</button>")) 18 computed_role = self.marionette.find_element(By.ID, "a").computed_role 19 self.assertEqual(computed_role, "button") 20 21 def test_get_computed_role_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_role