Beispiel #1
0
class ChromeDriverObject(object):
    def __init__(self):
        self.ut = Utility()
        self.log = Logger()

    # Set chromedriver path
    # Pass the option 'headless' if it is needed to run chrome in headless
    # configuration
    def set_chromedriver_object(self, chromeArgs):
        try:
            chromeArgs = chromeArgs
            chromeOptions = webdriver.ChromeOptions()
            driver_path = self.ut.get_driver_path('/dependencies/dir_chromedriver/chromedriver')
            self.ut.set_executable_permission(driver_path)
            self.log.log_info("Setting executable permission to the chrome binary")
            self.log.log_info("Setting path of chromedriver")
            if not chromeArgs:
                driver = webdriver.Chrome(executable_path=driver_path)
            else:
                while '' in chromeArgs:
                    chromeArgs.remove('')
                for val in chromeArgs:
                    chromeOptions.add_argument(val)
                driver = webdriver.Chrome(executable_path=driver_path, options=chromeOptions)
            self.log.log_info("Path for chrome binary is set")
            return driver
        except WebDriverException as e:
            self.log.log_error("There is an exception in the Web Driver configuration")
            self.log.log_error(e)
Beispiel #2
0
class OperaDriverObject(object):
    def __init__(self):
        self.ut = Utility()
        self.ot = OS_type()
        self.log = Logger()

    # Set opera odriver path
    # Pass the option 'headless' if it is needed to run gecko in headless
    # configuration
    def set_operadriver_object(self):
        try:
            os_type = self.ot.os_name()
            driver = None
            if os_type == "macos":
                driver_path = self.ut.get_driver_path('/dependencies/dir_operadriver/operadriver_mac64/operadriver')
                self.ut.set_executable_permission(driver_path)
                self.log.log_info("Setting path of operadriver")
                driver = webdriver.Opera(executable_path=driver_path)
                self.log.log_info("Path for opera binary is set")
            if os_type == "linux":
                driver_path = self.ut.get_driver_path('/dependencies/dir_operadriver/operadriver_linux64/operadriver')
                self.ut.set_executable_permission(driver_path)
                self.log.log_info("Setting path of operadriver")
                driver = webdriver.Opera(executable_path=driver_path)
                self.log.log_info("Path for opera binary is set")
            return driver
        except WebDriverException as e:
            self.log.log_error("There is an exception in the Web Driver configuration")
            self.log.log_error(e)
Beispiel #3
0
class PhantomDriverObject(object):
    def __init__(self):
        self.ut = Utility()
        self.log = Logger()

    # Set chromedriver path
    # Pass the option 'headless' if it is needed to run chrome in headless
    # configuration

    def set_phantomdriver_object(self):
        try:
            driver_path = self.ut.get_driver_path('/dependencies/dir_phantomjsdriver/phantomjsdriver/bin/phantomjs')
            self.ut.set_executable_permission(driver_path)
            self.log.log_info("Setting executable permission to the phantom binary")
            driver = webdriver.PhantomJS(executable_path=driver_path)
            self.log.log_info("Path for phantom binary is set")
            return driver
        except WebDriverException as e:
            self.log.log_error("There is an exception in the Web Driver configuration")