|
41 | 41 | <a id="link-5" name="xxx" ng-click="value = 5">anchor</a> (no link)<br /> |
42 | 42 | <a id="link-6" ng-href="{{value}}">link</a> (link, change location) |
43 | 43 | </doc:source> |
44 | | - <doc:scenario> |
| 44 | + <doc:protractor> |
45 | 45 | it('should execute ng-click but not reload when href without value', function() { |
46 | | - element('#link-1').click(); |
47 | | - expect(input('value').val()).toEqual('1'); |
48 | | - expect(element('#link-1').attr('href')).toBe(""); |
| 46 | + element(by.id('link-1')).click(); |
| 47 | + expect(element(by.model('value')).getAttribute('value')).toEqual('1'); |
| 48 | + expect(element(by.id('link-1')).getAttribute('href')).toBe(''); |
49 | 49 | }); |
50 | 50 |
|
51 | 51 | it('should execute ng-click but not reload when href empty string', function() { |
52 | | - element('#link-2').click(); |
53 | | - expect(input('value').val()).toEqual('2'); |
54 | | - expect(element('#link-2').attr('href')).toBe(""); |
| 52 | + element(by.id('link-2')).click(); |
| 53 | + expect(element(by.model('value')).getAttribute('value')).toEqual('2'); |
| 54 | + expect(element(by.id('link-2')).getAttribute('href')).toBe(''); |
55 | 55 | }); |
56 | 56 |
|
57 | 57 | it('should execute ng-click and change url when ng-href specified', function() { |
58 | | - expect(element('#link-3').attr('href')).toBe("/123"); |
| 58 | + expect(element(by.id('link-3')).getAttribute('href')).toMatch(/\/123$/); |
59 | 59 |
|
60 | | - element('#link-3').click(); |
61 | | - expect(browser().window().path()).toEqual('/123'); |
| 60 | + element(by.id('link-3')).click(); |
| 61 | +
|
| 62 | + expect(browser.driver.getCurrentUrl()).toMatch(/\/123$/); |
62 | 63 | }); |
63 | 64 |
|
64 | 65 | it('should execute ng-click but not reload when href empty string and name specified', function() { |
65 | | - element('#link-4').click(); |
66 | | - expect(input('value').val()).toEqual('4'); |
67 | | - expect(element('#link-4').attr('href')).toBe(''); |
| 66 | + element(by.id('link-4')).click(); |
| 67 | + expect(element(by.model('value')).getAttribute('value')).toEqual('4'); |
| 68 | + expect(element(by.id('link-4')).getAttribute('href')).toBe(''); |
68 | 69 | }); |
69 | 70 |
|
70 | 71 | it('should execute ng-click but not reload when no href but name specified', function() { |
71 | | - element('#link-5').click(); |
72 | | - expect(input('value').val()).toEqual('5'); |
73 | | - expect(element('#link-5').attr('href')).toBe(undefined); |
| 72 | + element(by.id('link-5')).click(); |
| 73 | + expect(element(by.model('value')).getAttribute('value')).toEqual('5'); |
| 74 | + expect(element(by.id('link-5')).getAttribute('href')).toBe(null); |
74 | 75 | }); |
75 | 76 |
|
76 | 77 | it('should only change url when only ng-href', function() { |
77 | | - input('value').enter('6'); |
78 | | - expect(element('#link-6').attr('href')).toBe('6'); |
| 78 | + element(by.model('value')).clear(); |
| 79 | + element(by.model('value')).sendKeys('6'); |
| 80 | + expect(element(by.id('link-6')).getAttribute('href')).toMatch(/\/6$/); |
79 | 81 |
|
80 | | - element('#link-6').click(); |
81 | | - expect(browser().location().url()).toEqual('/6'); |
| 82 | + element(by.id('link-6')).click(); |
| 83 | + expect(browser.getCurrentUrl()).toMatch(/\/6$/); |
82 | 84 | }); |
83 | | - </doc:scenario> |
| 85 | + </doc:protractor> |
84 | 86 | </doc:example> |
85 | 87 | */ |
86 | 88 |
|
|
165 | 167 | Click me to toggle: <input type="checkbox" ng-model="checked"><br/> |
166 | 168 | <button ng-model="button" ng-disabled="checked">Button</button> |
167 | 169 | </doc:source> |
168 | | - <doc:scenario> |
| 170 | + <doc:protractor> |
169 | 171 | it('should toggle button', function() { |
170 | | - expect(element('.doc-example-live :button').prop('disabled')).toBeFalsy(); |
171 | | - input('checked').check(); |
172 | | - expect(element('.doc-example-live :button').prop('disabled')).toBeTruthy(); |
| 172 | + expect(element(by.css('.doc-example-live button')).getAttribute('disabled')).toBeFalsy(); |
| 173 | + element(by.model('checked')).click(); |
| 174 | + expect(element(by.css('.doc-example-live button')).getAttribute('disabled')).toBeTruthy(); |
173 | 175 | }); |
174 | | - </doc:scenario> |
| 176 | + </doc:protractor> |
175 | 177 | </doc:example> |
176 | 178 | * |
177 | 179 | * @element INPUT |
|
200 | 202 | Check me to check both: <input type="checkbox" ng-model="master"><br/> |
201 | 203 | <input id="checkSlave" type="checkbox" ng-checked="master"> |
202 | 204 | </doc:source> |
203 | | - <doc:scenario> |
| 205 | + <doc:protractor> |
204 | 206 | it('should check both checkBoxes', function() { |
205 | | - expect(element('.doc-example-live #checkSlave').prop('checked')).toBeFalsy(); |
206 | | - input('master').check(); |
207 | | - expect(element('.doc-example-live #checkSlave').prop('checked')).toBeTruthy(); |
| 207 | + expect(element(by.id('checkSlave')).getAttribute('checked')).toBeFalsy(); |
| 208 | + element(by.model('master')).click(); |
| 209 | + expect(element(by.id('checkSlave')).getAttribute('checked')).toBeTruthy(); |
208 | 210 | }); |
209 | | - </doc:scenario> |
| 211 | + </doc:protractor> |
210 | 212 | </doc:example> |
211 | 213 | * |
212 | 214 | * @element INPUT |
|
235 | 237 | Check me to make text readonly: <input type="checkbox" ng-model="checked"><br/> |
236 | 238 | <input type="text" ng-readonly="checked" value="I'm Angular"/> |
237 | 239 | </doc:source> |
238 | | - <doc:scenario> |
| 240 | + <doc:protractor> |
239 | 241 | it('should toggle readonly attr', function() { |
240 | | - expect(element('.doc-example-live :text').prop('readonly')).toBeFalsy(); |
241 | | - input('checked').check(); |
242 | | - expect(element('.doc-example-live :text').prop('readonly')).toBeTruthy(); |
| 242 | + expect(element(by.css('.doc-example-live [type="text"]')).getAttribute('readonly')).toBeFalsy(); |
| 243 | + element(by.model('checked')).click(); |
| 244 | + expect(element(by.css('.doc-example-live [type="text"]')).getAttribute('readonly')).toBeTruthy(); |
243 | 245 | }); |
244 | | - </doc:scenario> |
| 246 | + </doc:protractor> |
245 | 247 | </doc:example> |
246 | 248 | * |
247 | 249 | * @element INPUT |
|
274 | 276 | <option id="greet" ng-selected="selected">Greetings!</option> |
275 | 277 | </select> |
276 | 278 | </doc:source> |
277 | | - <doc:scenario> |
| 279 | + <doc:protractor> |
278 | 280 | it('should select Greetings!', function() { |
279 | | - expect(element('.doc-example-live #greet').prop('selected')).toBeFalsy(); |
280 | | - input('selected').check(); |
281 | | - expect(element('.doc-example-live #greet').prop('selected')).toBeTruthy(); |
| 281 | + expect(element(by.id('greet')).getAttribute('selected')).toBeFalsy(); |
| 282 | + element(by.model('selected')).click(); |
| 283 | + expect(element(by.id('greet')).getAttribute('selected')).toBeTruthy(); |
282 | 284 | }); |
283 | | - </doc:scenario> |
| 285 | + </doc:protractor> |
284 | 286 | </doc:example> |
285 | 287 | * |
286 | 288 | * @element OPTION |
|
310 | 312 | <summary>Show/Hide me</summary> |
311 | 313 | </details> |
312 | 314 | </doc:source> |
313 | | - <doc:scenario> |
| 315 | + <doc:protractor> |
314 | 316 | it('should toggle open', function() { |
315 | | - expect(element('#details').prop('open')).toBeFalsy(); |
316 | | - input('open').check(); |
317 | | - expect(element('#details').prop('open')).toBeTruthy(); |
| 317 | + expect(element(by.id('details')).getAttribute('open')).toBeFalsy(); |
| 318 | + element(by.model('open')).click(); |
| 319 | + expect(element(by.id('details')).getAttribute('open')).toBeTruthy(); |
318 | 320 | }); |
319 | | - </doc:scenario> |
| 321 | + </doc:protractor> |
320 | 322 | </doc:example> |
321 | 323 | * |
322 | 324 | * @element DETAILS |
|
0 commit comments