tor-browser

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

test_chrome_text.py (1400B)


      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 import os
      6 import sys
      7 
      8 from marionette_driver.by import By
      9 from marionette_harness import MarionetteTestCase, WindowManagerMixin
     10 
     11 # add this directory to the path
     12 sys.path.append(os.path.dirname(__file__))
     13 
     14 from chrome_handler_mixin import ChromeHandlerMixin
     15 
     16 
     17 class TestTextChrome(ChromeHandlerMixin, WindowManagerMixin, MarionetteTestCase):
     18    def setUp(self):
     19        super(TestTextChrome, self).setUp()
     20        win = self.open_chrome_window(self.chrome_base_url + "test_xul.xhtml")
     21        self.marionette.switch_to_window(win)
     22 
     23        self.marionette.set_context("chrome")
     24 
     25    def tearDown(self):
     26        self.close_all_windows()
     27 
     28        super(TestTextChrome, self).tearDown()
     29 
     30    def test_get_text(self):
     31        elem = self.marionette.find_element(By.ID, "testBox")
     32        self.assertEqual(elem.text, "box")
     33 
     34    def test_clear_text(self):
     35        input = self.marionette.find_element(By.ID, "textInput")
     36        self.assertEqual(
     37            "test",
     38            self.marionette.execute_script("return arguments[0].value;", [input]),
     39        )
     40        input.clear()
     41        self.assertEqual(
     42            "", self.marionette.execute_script("return arguments[0].value;", [input])
     43        )