OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """WebsiteTest testing class.""" | 5 """WebsiteTest testing class.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 """Does the wrong login test: Tries to login with a wrong password and | 297 """Does the wrong login test: Tries to login with a wrong password and |
298 checks that the password is not saved. | 298 checks that the password is not saved. |
299 | 299 |
300 Raises: | 300 Raises: |
301 Exception: An exception is raised if the test fails: If there is a | 301 Exception: An exception is raised if the test fails: If there is a |
302 problem when performing the login (ex: the login button is not | 302 problem when performing the login (ex: the login button is not |
303 available ...), if the state of the username and password fields is | 303 available ...), if the state of the username and password fields is |
304 not like we expected or if the password is saved. | 304 not like we expected or if the password is saved. |
305 """ | 305 """ |
306 logging.info("\nWrong Login Test for %s \n" % self.name) | 306 logging.info("\nWrong Login Test for %s \n" % self.name) |
307 correct_password = self.password | 307 try: |
308 self.password = self.password + "1" | 308 correct_password = self.password |
309 self.LoginWhenNotAutofilled() | 309 self.password = self.password + "1" |
310 self.password = correct_password | 310 self.LoginWhenNotAutofilled() |
311 self.Wait(2) | 311 self.password = correct_password |
312 self.environment.SwitchToInternals() | 312 self.Wait(2) |
313 self.environment.CheckForNewMessage( | 313 self.environment.SwitchToInternals() |
314 environment.MESSAGE_SAVE, | 314 self.environment.CheckForNewMessage( |
315 False, | 315 environment.MESSAGE_SAVE, |
316 "Error: password manager thinks that a login with wrong password was " | 316 False, |
317 "successful for the following website : %s \n" % self.name) | 317 "Error: password manager thinks that a login with wrong password was " |
318 self.environment.SwitchFromInternals() | 318 "successful for the following website : %s \n" % self.name) |
| 319 finally: |
| 320 self.environment.SwitchFromInternals() |
319 | 321 |
320 def SuccessfulLoginTest(self): | 322 def SuccessfulLoginTest(self): |
321 """Does the successful login when the password is not expected to be | 323 """Does the successful login when the password is not expected to be |
322 autofilled test: Checks that the password is not autofilled, tries to login | 324 autofilled test: Checks that the password is not autofilled, tries to login |
323 with a right password and checks if the password is saved. Then logs out. | 325 with a right password and checks if the password is saved. Then logs out. |
324 | 326 |
325 Raises: | 327 Raises: |
326 Exception: An exception is raised if the test fails: If there is a | 328 Exception: An exception is raised if the test fails: If there is a |
327 problem when performing the login and the logout (ex: the login | 329 problem when performing the login and the logout (ex: the login |
328 button is not available ...), if the state of the username and | 330 button is not available ...), if the state of the username and |
329 password fields is not like we expected or if the password is not | 331 password fields is not like we expected or if the password is not |
330 saved. | 332 saved. |
331 """ | 333 """ |
332 logging.info("\nSuccessful Login Test for %s \n" % self.name) | 334 logging.info("\nSuccessful Login Test for %s \n" % self.name) |
333 self.LoginWhenNotAutofilled() | 335 try: |
334 self.Wait(2) | 336 self.LoginWhenNotAutofilled() |
335 self.environment.SwitchToInternals() | 337 self.Wait(2) |
336 self.environment.CheckForNewMessage( | 338 self.environment.SwitchToInternals() |
337 environment.MESSAGE_SAVE, | 339 self.environment.CheckForNewMessage( |
338 True, | 340 environment.MESSAGE_SAVE, |
339 "Error: password manager hasn't detected a successful login for the " | 341 True, |
340 "following website : %s \n" | 342 "Error: password manager hasn't detected a successful login for the " |
341 % self.name) | 343 "following website : %s \n" |
342 self.environment.SwitchFromInternals() | 344 % self.name) |
343 self.Logout() | 345 finally: |
| 346 self.environment.SwitchFromInternals() |
| 347 self.Logout() |
344 | 348 |
345 def SuccessfulLoginWithAutofilledPasswordTest(self): | 349 def SuccessfulLoginWithAutofilledPasswordTest(self): |
346 """Does the successful login when the password is expected to be autofilled | 350 """Does the successful login when the password is expected to be autofilled |
347 test: Checks that the password is autofilled, tries to login with the | 351 test: Checks that the password is autofilled, tries to login with the |
348 autofilled password and checks if the password is saved. Then logs out. | 352 autofilled password and checks if the password is saved. Then logs out. |
349 | 353 |
350 Raises: | 354 Raises: |
351 Exception: An exception is raised if the test fails: If there is a | 355 Exception: An exception is raised if the test fails: If there is a |
352 problem when performing the login and the logout (ex: the login | 356 problem when performing the login and the logout (ex: the login |
353 button is not available ...), if the state of the username and | 357 button is not available ...), if the state of the username and |
354 password fields is not like we expected or if the password is not | 358 password fields is not like we expected or if the password is not |
355 saved. | 359 saved. |
356 """ | 360 """ |
357 logging.info("\nSuccessful Login With Autofilled Password" | 361 logging.info("\nSuccessful Login With Autofilled Password" |
358 " Test %s \n" % self.name) | 362 " Test %s \n" % self.name) |
359 self.LoginWhenAutofilled() | 363 try: |
360 self.Wait(2) | 364 self.LoginWhenAutofilled() |
361 self.environment.SwitchToInternals() | 365 self.Wait(2) |
362 self.environment.CheckForNewMessage( | 366 self.environment.SwitchToInternals() |
363 environment.MESSAGE_SAVE, | 367 self.environment.CheckForNewMessage( |
364 True, | 368 environment.MESSAGE_SAVE, |
365 "Error: password manager hasn't detected a successful login for the " | 369 True, |
366 "following website : %s \n" | 370 "Error: password manager hasn't detected a successful login for the " |
367 % self.name) | 371 "following website : %s \n" |
368 self.environment.SwitchFromInternals() | 372 % self.name) |
369 self.Logout() | 373 finally: |
| 374 self.environment.SwitchFromInternals() |
| 375 self.Logout() |
370 | 376 |
371 def PromptTest(self): | 377 def PromptTest(self): |
372 """Does the prompt test: Tries to login with a wrong password and | 378 """Does the prompt test: Tries to login with a wrong password and |
373 checks that the prompt is not shown. Then tries to login with a right | 379 checks that the prompt is not shown. Then tries to login with a right |
374 password and checks that the prompt is not shown. | 380 password and checks that the prompt is not shown. |
375 | 381 |
376 Raises: | 382 Raises: |
377 Exception: An exception is raised if the test fails: If there is a | 383 Exception: An exception is raised if the test fails: If there is a |
378 problem when performing the login (ex: the login button is not | 384 problem when performing the login (ex: the login button is not |
379 available ...), if the state of the username and password fields is | 385 available ...), if the state of the username and password fields is |
380 not like we expected or if the prompt is not shown for the right | 386 not like we expected or if the prompt is not shown for the right |
381 password or is shown for a wrong one. | 387 password or is shown for a wrong one. |
382 """ | 388 """ |
383 logging.info("\nPrompt Test for %s \n" % self.name) | 389 logging.info("\nPrompt Test for %s \n" % self.name) |
384 correct_password = self.password | 390 try: |
385 self.password = self.password + "1" | 391 correct_password = self.password |
386 self.LoginWhenNotAutofilled() | 392 self.password = self.password + "1" |
387 self.password = correct_password | 393 self.LoginWhenNotAutofilled() |
388 self.Wait(2) | 394 self.password = correct_password |
389 self.environment.SwitchToInternals() | 395 self.Wait(2) |
390 self.environment.CheckForNewMessage( | 396 self.environment.SwitchToInternals() |
391 environment.MESSAGE_ASK, | 397 self.environment.CheckForNewMessage( |
392 False, | 398 environment.MESSAGE_ASK, |
393 "Error: password manager thinks that a login with wrong password was " | 399 False, |
394 "successful for the following website : %s \n" % self.name) | 400 "Error: password manager thinks that a login with wrong password was " |
395 self.environment.SwitchFromInternals() | 401 "successful for the following website : %s \n" % self.name) |
| 402 self.environment.SwitchFromInternals() |
396 | 403 |
397 self.LoginWhenNotAutofilled() | 404 self.LoginWhenNotAutofilled() |
398 self.Wait(2) | 405 self.Wait(2) |
399 self.environment.SwitchToInternals() | 406 self.environment.SwitchToInternals() |
400 self.environment.CheckForNewMessage( | 407 self.environment.CheckForNewMessage( |
401 environment.MESSAGE_ASK, | 408 environment.MESSAGE_ASK, |
402 True, | 409 True, |
403 "Error: password manager hasn't detected a successful login for the " | 410 "Error: password manager hasn't detected a successful login for the " |
404 "following website : %s \n" % self.name) | 411 "following website : %s \n" % self.name) |
405 self.environment.SwitchFromInternals() | 412 finally: |
| 413 self.environment.SwitchFromInternals() |
OLD | NEW |