| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Automated tests for many websites""" | 6 """Automated tests for many websites""" |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import logging | 9 import logging |
| 10 | 10 |
| 11 from environment import Environment | 11 from environment import Environment |
| 12 from websitetest import WebsiteTest | 12 from websitetest import WebsiteTest |
| 13 | 13 |
| 14 | 14 |
| 15 class TypeOfTestedWebsites: | 15 class TypeOfTestedWebsites: |
| 16 """An enum to specify which groups of tests to run.""" | 16 """An enum to specify which groups of tests to run.""" |
| 17 # Runs only the disabled tests. | 17 # Runs only the disabled tests. |
| 18 # TODO(vabr): Remove this option. |
| 18 DISABLED_TESTS = 0 | 19 DISABLED_TESTS = 0 |
| 19 # Runs only the enabled tests. | 20 # Runs only the enabled tests. |
| 20 ENABLED_TESTS = 1 | 21 ENABLED_TESTS = 1 |
| 21 # Runs all the tests. | 22 # Runs all the tests. |
| 22 ALL_TESTS = 2 | 23 ALL_TESTS = 2 |
| 23 # Runs a specified list of tests. | 24 # Runs a specified list of tests. |
| 24 LIST_OF_TESTS = 3 | 25 LIST_OF_TESTS = 3 |
| 25 | 26 |
| 26 def __init__(self): | 27 def __init__(self): |
| 27 pass | 28 pass |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 self.GoTo("https://vube.com") | 258 self.GoTo("https://vube.com") |
| 258 self.Click("[vube-login='']") | 259 self.Click("[vube-login='']") |
| 259 self.FillUsernameInto("[ng-model='login.user']") | 260 self.FillUsernameInto("[ng-model='login.user']") |
| 260 self.FillPasswordInto("[ng-model='login.pass']") | 261 self.FillPasswordInto("[ng-model='login.pass']") |
| 261 while (self.IsDisplayed("[ng-model='login.pass']") | 262 while (self.IsDisplayed("[ng-model='login.pass']") |
| 262 and not self.IsDisplayed(".prompt.alert")): | 263 and not self.IsDisplayed(".prompt.alert")): |
| 263 self.ClickIfClickable("[ng-click='login()']") | 264 self.ClickIfClickable("[ng-click='login()']") |
| 264 self.Wait(1) | 265 self.Wait(1) |
| 265 | 266 |
| 266 | 267 |
| 267 def Tests(environment): | 268 def Tests(environment, tests_to_run=None): |
| 268 | 269 |
| 270 working_tests = { |
| 271 "facebook": Facebook("facebook"), |
| 272 "google": Google("google"), |
| 273 "linkedin": Linkedin("linkedin"), |
| 274 "mailru": Mailru("mailru"), |
| 275 "nytimes": Nytimes("nytimes"), |
| 276 "odnoklassniki": Odnoklassniki("odnoklassniki"), |
| 277 "pinterest": Pinterest("pinterest"), |
| 278 "reddit": Reddit("reddit", username_not_auto=True), |
| 279 "tumblr": Tumblr("tumblr", username_not_auto=True), |
| 280 "twitter": Twitter("twitter"), |
| 281 "wikipedia": Wikipedia("wikipedia", username_not_auto=True), |
| 282 "yahoo": Yahoo("yahoo", username_not_auto=True), |
| 283 "yandex": Yandex("yandex") |
| 284 } |
| 269 | 285 |
| 270 # Working tests. | 286 disabled_tests = { |
| 287 "amazon": Amazon("amazon"), # Bug not reproducible without test. |
| 288 "ask": Ask("ask"), # Password not saved. |
| 289 "baidu": Baidu("baidu"), # Password not saved. |
| 290 "cnn": Cnn("cnn"), # http://crbug.com/368690 |
| 291 "ebay": Ebay("ebay"), # http://crbug.com/368690 |
| 292 "espn": Espn("espn"), # Iframe, password saved but not autofileld. |
| 293 "live": Live("live", username_not_auto=True), # http://crbug.com/367768 |
| 294 "163": One63("163"), # http://crbug.com/368690 |
| 295 "vube": Vube("vube"), # http://crbug.com/368690 |
| 296 } |
| 271 | 297 |
| 298 if tests_to_run: |
| 299 for test in tests_to_run: |
| 300 if (test not in working_tests.keys() and |
| 301 test not in disabled_tests.keys()): |
| 302 print "Skip test: test {} is not in known tests".format(test) |
| 303 continue |
| 304 if test in working_tests.keys(): |
| 305 test_class = working_tests[test] |
| 306 else: |
| 307 test_class = disabled_tests[test] |
| 308 environment.AddWebsiteTest(test_class) |
| 309 else: |
| 310 for _, test in working_tests: |
| 311 environment.AddWebsiteTest(test) |
| 312 for _, test in disabled_tests: |
| 313 environment.AddWebsiteTest(test, disabled=True) |
| 272 | 314 |
| 273 environment.AddWebsiteTest(Facebook("facebook")) | |
| 274 | |
| 275 environment.AddWebsiteTest(Google("google")) | |
| 276 | |
| 277 environment.AddWebsiteTest(Linkedin("linkedin")) | |
| 278 | |
| 279 environment.AddWebsiteTest(Mailru("mailru")) | |
| 280 | |
| 281 environment.AddWebsiteTest(Nytimes("nytimes")) | |
| 282 | |
| 283 environment.AddWebsiteTest(Odnoklassniki("odnoklassniki")) | |
| 284 | |
| 285 environment.AddWebsiteTest(Pinterest("pinterest")) | |
| 286 | |
| 287 environment.AddWebsiteTest(Reddit("reddit", username_not_auto=True)) | |
| 288 | |
| 289 environment.AddWebsiteTest(Tumblr("tumblr", username_not_auto=True)) | |
| 290 | |
| 291 environment.AddWebsiteTest(Twitter("twitter")) | |
| 292 | |
| 293 environment.AddWebsiteTest(Wikipedia("wikipedia", username_not_auto=True)) | |
| 294 | |
| 295 environment.AddWebsiteTest(Yahoo("yahoo", username_not_auto=True)) | |
| 296 | |
| 297 environment.AddWebsiteTest(Yandex("yandex")) | |
| 298 | |
| 299 # Disabled tests. | |
| 300 | |
| 301 | |
| 302 # Bug not reproducible without test. | |
| 303 environment.AddWebsiteTest(Amazon("amazon"), disabled=True) | |
| 304 | |
| 305 # Password not saved. | |
| 306 environment.AddWebsiteTest(Ask("ask"), disabled=True) | |
| 307 | |
| 308 # Password not saved. | |
| 309 environment.AddWebsiteTest(Baidu("baidu"), disabled=True) | |
| 310 | |
| 311 # http://crbug.com/368690 | |
| 312 environment.AddWebsiteTest(Cnn("cnn"), disabled=True) | |
| 313 | |
| 314 # http://crbug.com/368690 | |
| 315 environment.AddWebsiteTest(Ebay("ebay"), disabled=True) | |
| 316 | |
| 317 # Iframe, password saved but not autofileld. | |
| 318 environment.AddWebsiteTest(Espn("espn"), disabled=True) | |
| 319 | |
| 320 # http://crbug.com/367768 | |
| 321 environment.AddWebsiteTest(Live("live", username_not_auto=True), | |
| 322 disabled=True) | |
| 323 | |
| 324 # http://crbug.com/368690 | |
| 325 environment.AddWebsiteTest(One63("163"), disabled=True) | |
| 326 | |
| 327 # http://crbug.com/368690 | |
| 328 environment.AddWebsiteTest(Vube("vube"), disabled=True) | |
| 329 | 315 |
| 330 def saveResults(environment_tests_results, environment_save_path): | 316 def saveResults(environment_tests_results, environment_save_path): |
| 331 """Save the test results in an xml file. | 317 """Save the test results in an xml file. |
| 332 | 318 |
| 333 Args: | 319 Args: |
| 334 environment_tests_results: A list of the TestResults that are going to be | 320 environment_tests_results: A list of the TestResults that are going to be |
| 335 saved. | 321 saved. |
| 336 environment_save_path: The file where the results are going to be saved. | 322 environment_save_path: The file where the results are going to be saved. |
| 337 If it's None, the results are not going to be stored. | 323 If it's None, the results are not going to be stored. |
| 338 Raises: | 324 Raises: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 environment_passwords_path, | 367 environment_passwords_path, |
| 382 enable_automatic_password_saving, | 368 enable_automatic_password_saving, |
| 383 environment_numeric_level, | 369 environment_numeric_level, |
| 384 log_to_console, | 370 log_to_console, |
| 385 environment_log_file) | 371 environment_log_file) |
| 386 | 372 |
| 387 # Test which care about the save-password prompt need the prompt | 373 # Test which care about the save-password prompt need the prompt |
| 388 # to be shown. Automatic password saving results in no prompt. | 374 # to be shown. Automatic password saving results in no prompt. |
| 389 run_prompt_tests = not enable_automatic_password_saving | 375 run_prompt_tests = not enable_automatic_password_saving |
| 390 | 376 |
| 391 Tests(environment) | 377 Tests(environment, tests) |
| 392 | 378 |
| 393 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS: | 379 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS: |
| 394 environment.AllTests(run_prompt_tests) | 380 environment.AllTests(run_prompt_tests) |
| 395 elif environment_tested_websites == TypeOfTestedWebsites.DISABLED_TESTS: | 381 elif environment_tested_websites == TypeOfTestedWebsites.DISABLED_TESTS: |
| 396 environment.DisabledTests(run_prompt_tests) | 382 environment.DisabledTests(run_prompt_tests) |
| 397 elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS: | 383 elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS: |
| 398 environment.Test(tests, run_prompt_tests) | 384 environment.Test(tests, run_prompt_tests) |
| 399 elif environment_tested_websites == TypeOfTestedWebsites.ENABLED_TESTS: | 385 elif environment_tested_websites == TypeOfTestedWebsites.ENABLED_TESTS: |
| 400 environment.WorkingTests(run_prompt_tests) | 386 environment.WorkingTests(run_prompt_tests) |
| 401 else: | 387 else: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 args.profile_path[0], | 475 args.profile_path[0], |
| 490 passwords_path, | 476 passwords_path, |
| 491 True, | 477 True, |
| 492 numeric_level, | 478 numeric_level, |
| 493 args.log_screen, | 479 args.log_screen, |
| 494 log_file, | 480 log_file, |
| 495 tested_websites, | 481 tested_websites, |
| 496 args.tests) | 482 args.tests) |
| 497 | 483 |
| 498 saveResults(tests_results, save_path) | 484 saveResults(tests_results, save_path) |
| OLD | NEW |