From 0998763d133f199954a9787b34e9e39331903946 Mon Sep 17 00:00:00 2001 From: Zoia Date: Tue, 19 Feb 2019 11:42:45 +0300 Subject: [PATCH] Remove hardcoded driver name in tests #7 --- JDI/web/selenium/elements/composite/web_site.py | 4 ++-- JDI/web/selenium/settings/WebSettings.py | 3 ++- JDI/web/selenium/settings/web_settings.py | 3 ++- Test/jdi_uitest_web_examples/test/carrer_tests.py | 2 +- Test/jdi_uitests_webtests/test/composite/page_tests.py | 2 +- Test/jdi_uitests_webtests/test/init_tests.py | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/JDI/web/selenium/elements/composite/web_site.py b/JDI/web/selenium/elements/composite/web_site.py index 0efa374..d4b7d2f 100644 --- a/JDI/web/selenium/elements/composite/web_site.py +++ b/JDI/web/selenium/elements/composite/web_site.py @@ -10,6 +10,6 @@ def _init(site): WebCascadeInit().init_site_page(site) @staticmethod - def init(site, driver_name): - WebSettings.use_driver(driver_name) + def init(site): + WebSettings.use_driver() WebCascadeInit().init_site_page(site) diff --git a/JDI/web/selenium/settings/WebSettings.py b/JDI/web/selenium/settings/WebSettings.py index a571c72..17b08a9 100644 --- a/JDI/web/selenium/settings/WebSettings.py +++ b/JDI/web/selenium/settings/WebSettings.py @@ -17,7 +17,8 @@ def set_driver_factory(driver_factory): JDISettings._driver_factory = driver_factory @staticmethod - def use_driver(driver_name, options=[], capabilities={}, executor=None): + def use_driver(options=[], capabilities={}, executor=None): + driver_name = JDISettings.get_setting_by_name('driver') JDISettings._driver_factory = SeleniumDriverFactory() WebSettings.set_driver_factory(JDISettings._driver_factory) return JDISettings._driver_factory.register_driver(driver_name, options, capabilities, executor) diff --git a/JDI/web/selenium/settings/web_settings.py b/JDI/web/selenium/settings/web_settings.py index a571c72..17b08a9 100644 --- a/JDI/web/selenium/settings/web_settings.py +++ b/JDI/web/selenium/settings/web_settings.py @@ -17,7 +17,8 @@ def set_driver_factory(driver_factory): JDISettings._driver_factory = driver_factory @staticmethod - def use_driver(driver_name, options=[], capabilities={}, executor=None): + def use_driver(options=[], capabilities={}, executor=None): + driver_name = JDISettings.get_setting_by_name('driver') JDISettings._driver_factory = SeleniumDriverFactory() WebSettings.set_driver_factory(JDISettings._driver_factory) return JDISettings._driver_factory.register_driver(driver_name, options, capabilities, executor) diff --git a/Test/jdi_uitest_web_examples/test/carrer_tests.py b/Test/jdi_uitest_web_examples/test/carrer_tests.py index b5fec10..7d19db0 100644 --- a/Test/jdi_uitest_web_examples/test/carrer_tests.py +++ b/Test/jdi_uitest_web_examples/test/carrer_tests.py @@ -12,7 +12,7 @@ class CareerTests(unittest.TestCase): @classmethod def setUpClass(cls): - WebSite.init(EpamSite, "chrome") + WebSite.init(EpamSite) WebSettings.logger.info("\nRun Tests from '%s' file" % cls.__name__) def setUp(self): diff --git a/Test/jdi_uitests_webtests/test/composite/page_tests.py b/Test/jdi_uitests_webtests/test/composite/page_tests.py index 45c8089..5173baa 100644 --- a/Test/jdi_uitests_webtests/test/composite/page_tests.py +++ b/Test/jdi_uitests_webtests/test/composite/page_tests.py @@ -13,7 +13,7 @@ class PageTests(unittest.TestCase): def setUp(self): WebSettings.logger.info("Run Test %s" % self.id().split(".")[-1]) - WebSite.init(EpamJDISite, "chrome") + WebSite.init(EpamJDISite) WebSettings.logger.info("Run Tests") EpamJDISite.home_page.open() EpamJDISite.login_page.submit(User.default()) diff --git a/Test/jdi_uitests_webtests/test/init_tests.py b/Test/jdi_uitests_webtests/test/init_tests.py index 69b9b84..6c5608d 100644 --- a/Test/jdi_uitests_webtests/test/init_tests.py +++ b/Test/jdi_uitests_webtests/test/init_tests.py @@ -11,7 +11,7 @@ class InitTests(unittest.TestCase): @classmethod def setUpClass(cls): - WebSite.init(EpamJDISite, "chrome") + WebSite.init(EpamJDISite) WebSettings.logger.info("\nRun Tests from '%s' file" % cls.__name__) EpamJDISite.home_page.open() EpamJDISite.login_page.submit(User.default()) @@ -31,7 +31,7 @@ class W3CInit(unittest.TestCase): @classmethod def setUpClass(cls): - WebSite.init(W3cSite, "chrome") + WebSite.init(W3cSite) WebSettings.logger.info("Run Tests") W3cSite.frame_page.open()