How to use get_default_config_directory method in toolium

Best Python code snippet using toolium_python

test_cases.py

Source:test_cases.py Github

copy

Full Screen

...30 # Configure logger and properties31 if not isinstance(self, SeleniumTestCase):32 # By default config directory is located in test path33 if not self.config_files.config_directory:34 self.config_files.set_config_directory(DriverManager.get_default_config_directory())35 self.driver_wrapper = DriverManager.get_default_wrapper()36 self.config_files = DriverManager.initialize_config_files(self.config_files)37 self.driver_wrapper.configure(self.config_files, is_selenium_test=False)38 # Get config and logger instances39 self.config = self.driver_wrapper.config40 self.logger = logging.getLogger(__name__)41 self.logger.info("Running new test: %s", self.get_subclassmethod_name())42 def tearDown(self):43 py2_exception = sys.exc_info()[1]44 try:45 # Python 3.4+46 exception_info = self._outcome.errors[-1][1] if len(self._outcome.errors) > 0 else None47 exception = exception_info[1] if exception_info else None48 except AttributeError:49 try:50 # Python 3.351 exceptions_list = self._outcomeForDoCleanups.failures + self._outcomeForDoCleanups.errors52 exception = exceptions_list[0][1] if exceptions_list else None53 except AttributeError:54 # Python 2.755 exception = py2_exception56 if not exception:57 self._test_passed = True58 self.logger.info("The test '%s' has passed", self.get_subclassmethod_name())59 else:60 self._test_passed = False61 error_message = get_message_exception(exception)62 self.logger.error("The test '%s' has failed: %s", self.get_subclassmethod_name(), error_message)63class SeleniumTestCase(BasicTestCase):64 driver = None65 utils = None66 @classmethod67 def tearDownClass(cls):68 super(SeleniumTestCase, cls).tearDownClass()69 DriverManager.close_drivers(scope='class', test_name=cls.get_subclass_name())70 def setUp(self):71 if not self.config_files.config_directory:72 self.config_files.set_config_directory(DriverManager.get_default_config_directory())73 self.driver_wrapper = DriverManager.connect_default_driver_wrapper(config_files=self.config_files)74 SeleniumTestCase.driver = self.driver_wrapper.driver75 self.utils = self.driver_wrapper.utils76 file_suffix = self.get_method_name()77 def assert_screenshot_page_element(self, filename, threshold=0, exclude_elements=None, force=False):78 if exclude_elements is None:79 exclude_elements = []80 VisualTest(self.driver_wrapper, force).assert_screenshot(self.web_element, filename, file_suffix,81 threshold, exclude_elements)82 PageElement.assert_screenshot = assert_screenshot_page_element83 # Call BasicTestCase setUp84 super(SeleniumTestCase, self).setUp()85 def tearDown(self):86 # Call BasicTestCase tearDown87 super(SeleniumTestCase, self).tearDown()88 # Close drivers89 DriverManager.close_drivers(scope='function', test_name=self.get_subclassmethod_name(),90 test_passed=self._test_passed)91 def assert_screenshot(self, element, filename, threshold=0, exclude_elements=None, driver_wrapper=None,92 force=False):93 if exclude_elements is None:94 exclude_elements = []95 file_suffix = self.get_method_name()96 VisualTest(driver_wrapper, force).assert_screenshot(element, filename, file_suffix, threshold, exclude_elements)97 def assert_full_screenshot(self, filename, threshold=0, exclude_elements=None, driver_wrapper=None, force=False):98 if exclude_elements is None:99 exclude_elements = []100 file_suffix = self.get_method_name()101 VisualTest(driver_wrapper, force).assert_screenshot(None, filename, file_suffix, threshold, exclude_elements)102class AppiumTestCase(SeleniumTestCase):103 app_strings = None104 @property105 def driver(self):106 return SeleniumTestCase.driver107 def setUp(self):108 self.driver_wrapper = DriverManager.get_default_wrapper()109 if not self.driver_wrapper.driver and not self.config_files.config_directory:110 # By default config directory is located in test path111 self.config_files.set_config_directory(DriverManager.get_default_config_directory())112 super(AppiumTestCase, self).setUp()...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...13 vol.Optional('max_workers', default = 10): int,14 vol.Optional('devices', default = []): list,15 vol.Optional('presets', default = {}): dict16}, extra=vol.ALLOW_EXTRA)17def get_default_config_directory() -> str:18 """Get the default configuration directory"""19 base_dir = os.getenv('APPDATA') if os.name == "nt" \20 else os.path.expanduser('~')21 return os.path.join(base_dir, CONFIG_DIRECTORY)22def get_config_file(config_dir: str) -> str:23 """Finds a supported configuration fill in the provided directory"""24 config_path = os.path.join(config_dir, CONFIG_FILE_NAME)25 return config_path if os.path.isfile(config_path) else None26def create_default_config(config_dir: str) -> str:27 """Creates a default configuration in the provided directory"""28 config_path = os.path.join(config_dir, CONFIG_FILE_NAME)29 try:30 with open(config_path, 'wt') as file:31 yaml.dump(CORE_CONFIG_SCHEMA({}), file, default_flow_style=False)32 return config_path33 except IOError:34 print(('Unable to create default configuration file {}').format(config_path))35 return None36def ensure_config_file(config_dir: str) -> str:37 """Checks if a config file exsit, and otherwise creates one"""38 ensure_config_directory(config_dir)39 config_path = get_config_file(config_dir)40 if config_path is None:41 config_path = create_default_config(config_dir)42 return config_path43def ensure_config_directory(config_dir: str) -> None:44 """Validate that the config directory is valid."""45 # If an explict path is provided simply check if it exist and failfast46 # if it doesn't. Otherwise, if we have the default directory attempt to47 # create the file48 if not os.path.isdir(config_dir):49 if config_dir != get_default_config_directory():50 print(('Error: Invalid configuration directory {}').format(config_dir))51 sys.exit(1)52 try:53 os.mkdir(config_dir)54 except OSError:55 print(('Error: Unable to create configuration directory {}').format(config_dir))56 sys.exit(1)57def load_config(config_dir: str) -> dict:58 """Validates and loads the configuration file in the provided directory"""59 config_file = ensure_config_file(config_dir)60 print(('Loading configuration file from {}').format(config_dir))61 with open(config_file, 'rt') as file:62 config_yaml = yaml.safe_load(file)63 if config_yaml is None:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful