tor-browser

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

test_position.py (1322B)


      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.by import By
      8 
      9 from marionette_harness import MarionetteTestCase
     10 
     11 
     12 def inline(doc):
     13    return "data:text/html;charset=utf-8,{}".format(quote(doc))
     14 
     15 
     16 class TestPosition(MarionetteTestCase):
     17    def test_should_get_element_position_back(self):
     18        doc = """
     19        <head>
     20            <title>Rectangles</title>
     21            <style>
     22                div {
     23                    position: absolute;
     24                    margin: 0;
     25                    border: 0;
     26                    padding: 0;
     27                }
     28                #r {
     29                    background-color: red;
     30                    left: 11px;
     31                    top: 10px;
     32                    width: 48.666666667px;
     33                    height: 49.333333333px;
     34                }
     35            </style>
     36        </head>
     37        <body>
     38            <div id="r">r</div>
     39        </body>
     40        """
     41        self.marionette.navigate(inline(doc))
     42 
     43        r2 = self.marionette.find_element(By.ID, "r")
     44        location = r2.rect
     45        self.assertEqual(11, location["x"])
     46        self.assertEqual(10, location["y"])