test_chrome_element_css.py (1372B)
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 marionette_driver.by import By 6 7 from marionette_harness import MarionetteTestCase 8 9 10 class TestChromeElementCSS(MarionetteTestCase): 11 def get_element_computed_style(self, element, property): 12 return self.marionette.execute_script( 13 """ 14 const [el, prop] = arguments; 15 const elStyle = window.getComputedStyle(el); 16 return elStyle[prop];""", 17 script_args=(element, property), 18 sandbox=None, 19 ) 20 21 def test_we_can_get_css_value_on_chrome_element(self): 22 with self.marionette.using_context("chrome"): 23 identity_icon = self.marionette.find_element(By.ID, "identity-icon") 24 favicon_image = identity_icon.value_of_css_property("list-style-image") 25 self.assertIn("chrome://", favicon_image) 26 identity_box = self.marionette.find_element(By.ID, "identity-box") 27 expected_bg_colour = self.get_element_computed_style( 28 identity_box, "backgroundColor" 29 ) 30 actual_bg_colour = identity_box.value_of_css_property("background-color") 31 self.assertEqual(expected_bg_colour, actual_bg_colour)