summaryrefslogtreecommitdiffstats
path: root/testing/marionette/harness/marionette_harness/tests/unit/test_visibility.py
blob: 750ecf20a58efb7819aa03f8d9adac4035a624cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_driver.by import By

from marionette_harness import MarionetteTestCase


class TestVisibility(MarionetteTestCase):

    def testShouldAllowTheUserToTellIfAnElementIsDisplayedOrNot(self):
        test_html = self.marionette.absolute_url("javascriptPage.html")
        self.marionette.navigate(test_html)

        self.assertTrue(self.marionette.find_element(By.ID, "displayed").is_displayed())
        self.assertFalse(self.marionette.find_element(By.ID, "none").is_displayed())
        self.assertFalse(self.marionette.find_element(By.ID,
            "suppressedParagraph").is_displayed())
        self.assertFalse(self.marionette.find_element(By.ID, "hidden").is_displayed())

    def testVisibilityShouldTakeIntoAccountParentVisibility(self):
        test_html = self.marionette.absolute_url("javascriptPage.html")
        self.marionette.navigate(test_html)

        childDiv = self.marionette.find_element(By.ID, "hiddenchild")
        hiddenLink = self.marionette.find_element(By.ID, "hiddenlink")

        self.assertFalse(childDiv.is_displayed())
        self.assertFalse(hiddenLink.is_displayed())

    def testShouldCountElementsAsVisibleIfStylePropertyHasBeenSet(self):
        test_html = self.marionette.absolute_url("javascriptPage.html")
        self.marionette.navigate(test_html)
        shown = self.marionette.find_element(By.ID, "visibleSubElement")
        self.assertTrue(shown.is_displayed())

    def testShouldModifyTheVisibilityOfAnElementDynamically(self):
        test_html = self.marionette.absolute_url("javascriptPage.html")
        self.marionette.navigate(test_html)
        element = self.marionette.find_element(By.ID, "hideMe")
        self.assertTrue(element.is_displayed())
        element.click()
        self.assertFalse(element.is_displayed())

    def testHiddenInputElementsAreNeverVisible(self):
        test_html = self.marionette.absolute_url("javascriptPage.html")
        self.marionette.navigate(test_html)

        shown = self.marionette.find_element(By.NAME, "hidden")

        self.assertFalse(shown.is_displayed())

    def testShouldSayElementsWithNegativeTransformAreNotDisplayed(self):
        test_html = self.marionette.absolute_url("cssTransform.html")
        self.marionette.navigate(test_html)

        elementX = self.marionette.find_element(By.ID, 'parentX')
        self.assertFalse(elementX.is_displayed())
        elementY = self.marionette.find_element(By.ID, 'parentY')
        self.assertFalse(elementY.is_displayed())

    def testShouldSayElementsWithParentWithNegativeTransformAreNotDisplayed(self):
        test_html = self.marionette.absolute_url("cssTransform.html")
        self.marionette.navigate(test_html)

        elementX = self.marionette.find_element(By.ID, 'childX')
        self.assertFalse(elementX.is_displayed())
        elementY = self.marionette.find_element(By.ID, 'childY')
        self.assertFalse(elementY.is_displayed())

    def testShouldSayElementWithZeroTransformIsVisible(self):
        test_html = self.marionette.absolute_url("cssTransform.html")
        self.marionette.navigate(test_html)

        zero_tranform = self.marionette.find_element(By.ID, 'zero-tranform')
        self.assertTrue(zero_tranform.is_displayed())

    def testShouldSayElementIsVisibleWhenItHasNegativeTransformButElementisntInANegativeSpace(self):
        test_html = self.marionette.absolute_url("cssTransform2.html")
        self.marionette.navigate(test_html)
        negative_percent__tranform = self.marionette.find_element(By.ID, 'negative-percentage-transformY')
        self.assertTrue(negative_percent__tranform.is_displayed())

    def testShouldSayElementIsInvisibleWhenOverflowXIsHiddenAndOutOfViewport(self):
        test_html = self.marionette.absolute_url("bug814037.html")
        self.marionette.navigate(test_html)
        overflow_x = self.marionette.find_element(By.ID, "assertMe2")
        self.assertFalse(overflow_x.is_displayed())

    def testShouldShowElementNotVisibleWithHiddenAttribute(self):
        test_html = self.marionette.absolute_url("hidden.html")
        self.marionette.navigate(test_html)
        singleHidden = self.marionette.find_element(By.ID, 'singleHidden')
        self.assertFalse(singleHidden.is_displayed())

    def testShouldShowElementNotVisibleWhenParentElementHasHiddenAttribute(self):
        test_html = self.marionette.absolute_url("hidden.html")
        self.marionette.navigate(test_html)
        child = self.marionette.find_element(By.ID, 'child')
        self.assertFalse(child.is_displayed())

    def testShouldClickOnELementPartiallyOffLeft(self):
        test_html = self.marionette.absolute_url("element_left.html")
        self.marionette.navigate(test_html)
        self.marionette.find_element(By.CSS_SELECTOR, '.element').click()

    def testShouldClickOnELementPartiallyOffRight(self):
        test_html = self.marionette.absolute_url("element_right.html")
        self.marionette.navigate(test_html)
        self.marionette.find_element(By.CSS_SELECTOR, '.element').click()

    def testShouldClickOnELementPartiallyOffTop(self):
        test_html = self.marionette.absolute_url("element_top.html")
        self.marionette.navigate(test_html)
        self.marionette.find_element(By.CSS_SELECTOR, '.element').click()

    def testShouldClickOnELementPartiallyOffBottom(self):
        test_html = self.marionette.absolute_url("element_bottom.html")
        self.marionette.navigate(test_html)
        self.marionette.find_element(By.CSS_SELECTOR, '.element').click()