|
16 | 16 | limitations under the License.
|
17 | 17 | -->
|
18 | 18 | <html>
|
| 19 | + |
19 | 20 | <head>
|
20 | 21 | <title>attribute_test.html</title>
|
21 | 22 | <script src="test_bootstrap.js"></script>
|
|
25 | 26 | goog.require('goog.events.EventType');
|
26 | 27 | goog.require('goog.testing.jsunit');
|
27 | 28 | </script>
|
| 29 | + <meta charset="UTF-8"> |
28 | 30 | <script type="text/javascript">
|
29 | 31 | function testCanFindNamedAttributes() {
|
30 |
| - var e = bot.locators.findElement({id: 'cheddar'}); |
| 32 | + var e = bot.locators.findElement({ id: 'cheddar' }); |
31 | 33 | assertAttributeEquals('cheese', e, 'name');
|
32 | 34 | }
|
33 | 35 |
|
34 | 36 | function testCanFindAttributesOnTheExpando() {
|
35 |
| - var e = bot.locators.findElement({id: 'cheddar'}); |
| 37 | + var e = bot.locators.findElement({ id: 'cheddar' }); |
36 | 38 | assertAttributeEquals('lovely', e, 'unknown');
|
37 | 39 | }
|
38 | 40 |
|
39 | 41 | function testShouldReturnClassAttribute() {
|
40 |
| - var e = bot.locators.findElement({id: 'cheddar'}); |
| 42 | + var e = bot.locators.findElement({ id: 'cheddar' }); |
41 | 43 | assertAttributeEquals('tasty', e, 'class');
|
42 | 44 | }
|
43 | 45 |
|
44 | 46 | function testShouldReturnNullForMissingAttributes() {
|
45 |
| - var e = bot.locators.findElement({id: 'checky'}); |
| 47 | + var e = bot.locators.findElement({ id: 'checky' }); |
46 | 48 | assertAttributeEquals(null, e, 'never_there');
|
47 | 49 | assertAttributeEquals(null, e, 'class');
|
48 | 50 | }
|
49 | 51 |
|
50 | 52 | function testShouldReturnAnEmptyStringWhenAttributesValueIsAnEmptyString() {
|
51 |
| - var e = bot.locators.findElement({id: 'cheddar'}); |
| 53 | + var e = bot.locators.findElement({ id: 'cheddar' }); |
52 | 54 | assertAttributeEquals('', e, 'empty');
|
53 | 55 | }
|
54 | 56 |
|
|
58 | 60 | assertEquals(String(elem.getAttribute(attr)), value);
|
59 | 61 | }
|
60 | 62 |
|
61 |
| - var e = bot.locators.findElement({id: 'selecty'}); |
| 63 | + var e = bot.locators.findElement({ id: 'selecty' }); |
62 | 64 | assertPresentBooleanAttr(e, 'selected');
|
63 | 65 |
|
64 |
| - var e = bot.locators.findElement({id: 'checky'}); |
| 66 | + var e = bot.locators.findElement({ id: 'checky' }); |
65 | 67 | assertPresentBooleanAttr(e, 'disabled');
|
66 | 68 | assertPresentBooleanAttr(e, 'readonly');
|
67 | 69 | assertPresentBooleanAttr(e, 'checked');
|
68 | 70 | }
|
69 | 71 |
|
70 | 72 | function testReturnNullForAbsentBooleanAttributes() {
|
71 |
| - var e = bot.locators.findElement({id: 'unselecty'}); |
| 73 | + var e = bot.locators.findElement({ id: 'unselecty' }); |
72 | 74 | assertAttributeEquals(null, e, 'selected');
|
73 | 75 |
|
74 |
| - var e = bot.locators.findElement({id: 'unchecky'}); |
| 76 | + var e = bot.locators.findElement({ id: 'unchecky' }); |
75 | 77 | assertAttributeEquals(null, e, 'disabled');
|
76 | 78 | assertAttributeEquals(null, e, 'readonly');
|
77 | 79 | assertAttributeEquals(null, e, 'checked');
|
78 | 80 | }
|
79 | 81 |
|
80 | 82 | function testCanGetValueAttributeFromInput() {
|
81 |
| - var input = bot.locators.findElement({id: 'unchecky'}); |
82 |
| - var option = bot.locators.findElement({id: 'unselecty'}); |
| 83 | + var input = bot.locators.findElement({ id: 'unchecky' }); |
| 84 | + var option = bot.locators.findElement({ id: 'unselecty' }); |
83 | 85 |
|
84 | 86 | assertAttributeEquals('unchecky', input, 'value');
|
85 | 87 | assertAttributeEquals('unselecty', option, 'value');
|
86 | 88 | }
|
87 | 89 |
|
88 | 90 | function testAttributeMatchesAreCaseInsensitive() {
|
89 |
| - var e = bot.locators.findElement({id: 'checky'}); |
| 91 | + var e = bot.locators.findElement({ id: 'checky' }); |
90 | 92 | assertAttributeEquals(bot.dom.getAttribute(e, 'readonly'), e, 'readOnly');
|
91 | 93 | assertAttributeEquals(bot.dom.getAttribute(e, 'name'), e, 'NaMe');
|
92 | 94 | }
|
93 | 95 |
|
| 96 | + function testAttributeDoesNotChangeTheTypeOfTheAttribute() { |
| 97 | + var e = bot.locators.findElement({ id: 'aValue' }); |
| 98 | + assertAttributeEquals("4b273a33fbbd29013nN93dy4F1A~", e, "value"); |
| 99 | + } |
| 100 | + |
94 | 101 | function assertAttributeEquals(expected, elem, attr) {
|
95 | 102 | assertEquals('Expected attribute "' + attr + '" to equal "' +
|
96 |
| - expected + '"', expected, bot.dom.getAttribute(elem, attr)); |
| 103 | + expected + '"', expected, bot.dom.getAttribute(elem, attr)); |
97 | 104 | }
|
98 | 105 |
|
99 | 106 | </script>
|
100 | 107 | </head>
|
| 108 | + |
101 | 109 | <body>
|
102 | 110 | <div id="cheddar" name="cheese" class="tasty" unknown="lovely" empty="">Cheddar</div>
|
103 | 111 |
|
|
107 | 115 | <option id="unselecty" value="unselecty">unselecty</option>
|
108 | 116 | </select>
|
109 | 117 | <!-- Setting checked="false" but getAttribute should be non-null. -->
|
110 |
| - <input id="checky" type="checkbox" disabled readonly="readonly" checked="false"/> |
111 |
| - <input id="unchecky" type="checkbox" value="unchecky"/> |
| 118 | + <input id="checky" type="checkbox" disabled readonly="readonly" checked="false" /> |
| 119 | + <input id="unchecky" type="checkbox" value="unchecky" /> |
112 | 120 | </form>
|
| 121 | + <li id=aValue value="4b273a33fbbd29013nN93dy4F1A~" class="cur"></li> |
113 | 122 | </body>
|
| 123 | + |
114 | 124 | </html>
|
0 commit comments