From dbd7a69ed3b013f6841fd5a7542f1c34b79838d1 Mon Sep 17 00:00:00 2001 From: wanghongjuan Date: Thu, 24 May 2018 17:27:15 +0800 Subject: [PATCH] [test] Add test for issue4637 - Add test for issue #4637 - This test is passed on v0.13.1 and v0.30.5 --- .../index.html | 10 ++++ .../package.json | 5 ++ .../test.py | 52 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 test/sanity/issue4637-chromiun-args-disable-logging/index.html create mode 100644 test/sanity/issue4637-chromiun-args-disable-logging/package.json create mode 100644 test/sanity/issue4637-chromiun-args-disable-logging/test.py diff --git a/test/sanity/issue4637-chromiun-args-disable-logging/index.html b/test/sanity/issue4637-chromiun-args-disable-logging/index.html new file mode 100644 index 0000000000..10e2c2c920 --- /dev/null +++ b/test/sanity/issue4637-chromiun-args-disable-logging/index.html @@ -0,0 +1,10 @@ + + + + + issue4637 + + +

Success

+ + diff --git a/test/sanity/issue4637-chromiun-args-disable-logging/package.json b/test/sanity/issue4637-chromiun-args-disable-logging/package.json new file mode 100644 index 0000000000..5926c9cdd6 --- /dev/null +++ b/test/sanity/issue4637-chromiun-args-disable-logging/package.json @@ -0,0 +1,5 @@ +{ + "name": "issue4637", + "main": "index.html", + "chromium-args": "--disable-logging" +} diff --git a/test/sanity/issue4637-chromiun-args-disable-logging/test.py b/test/sanity/issue4637-chromiun-args-disable-logging/test.py new file mode 100644 index 0000000000..244d0f1ffd --- /dev/null +++ b/test/sanity/issue4637-chromiun-args-disable-logging/test.py @@ -0,0 +1,52 @@ +import os +import sys +import shutil +import platform + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +from nw_util import * + +from selenium import webdriver +from selenium.webdriver.chrome.options import Options + +chrome_options = Options() +testdir = os.path.dirname(os.path.abspath(__file__)) +chrome_options.add_argument("nwapp=" + testdir) + +pkgname = 'issue4637' + +if platform.system() == "Windows": + user_data_dir = os.path.join(os.getenv('LOCALAPPDATA'), pkgname, "User Data") +elif platform.system() == 'Linux': + user_data_dir = os.path.join(os.getenv('HOME'), '.config', pkgname) +else: + user_data_dir = os.path.join(os.getenv('HOME'), 'Library', 'Application Support', pkgname) + +log_file = os.path.join(user_data_dir, "chrome_debug.log") + +try: + shutil.rmtree(user_data_dir) +except: + pass + +def check_cache(): + if os.path.exists(log_file): + print "Debug log file is enabled" + assert(False) + else: + print "Debug log file is disabled" + assert(True) + + +chrome_options.add_argument("user-data-dir=" + user_data_dir) + +driver = webdriver.Chrome(executable_path=os.environ["CHROMEDRIVER"], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"]) +driver.implicitly_wait(2) + +try: + print driver.current_url + check_cache() + output = wait_for_element_id_content(driver, "result", "Success") + assert("Success" in output) +finally: + driver.quit()