本文整理汇总了Python中toolium.driver_wrappers_pool.DriverWrappersPool类的典型用法代码示例。如果您正苦于以下问题:Python DriverWrappersPool类的具体用法?Python DriverWrappersPool怎么用?Python DriverWrappersPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DriverWrappersPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_logger
def configure_logger(self, tc_config_log_filename=None, tc_output_log_filename=None):
"""Configure selenium instance logger
:param tc_config_log_filename: test case specific logging config file
:param tc_output_log_filename: test case specific output logger file
"""
# Get config logger filename
config_log_filename = DriverWrappersPool.get_configured_value('Config_log_filename', tc_config_log_filename,
'logging.conf')
config_log_filename = os.path.join(DriverWrappersPool.config_directory, config_log_filename)
# Configure logger only if logging filename has changed
if self.config_log_filename != config_log_filename:
# Get output logger filename
output_log_filename = DriverWrappersPool.get_configured_value('Output_log_filename', tc_output_log_filename,
'toolium.log')
output_log_filename = os.path.join(DriverWrappersPool.output_directory, output_log_filename)
output_log_filename = output_log_filename.replace('\\', '\\\\')
try:
logging.config.fileConfig(config_log_filename, {'logfilename': output_log_filename}, False)
except Exception as exc:
print("[WARN] Error reading logging config file '{}': {}".format(config_log_filename, exc))
self.config_log_filename = config_log_filename
self.output_log_filename = output_log_filename
self.logger = logging.getLogger(__name__)
示例2: tearDown
def tearDown(self):
# Call BasicTestCase tearDown
super(SeleniumTestCase, self).tearDown()
# Close drivers
DriverWrappersPool.close_drivers(scope='function',
test_name=self.get_subclassmethod_name(),
test_passed=self._test_passed)
示例3: tearDownClass
def tearDownClass(cls):
# Call BasicTestCase tearDownClass
super(SeleniumTestCase, cls).tearDownClass()
# Close browser and stop driver if it has been reused
DriverWrappersPool.close_drivers_and_download_videos(cls.get_subclass_name())
SeleniumTestCase.driver = None
示例4: setUp
def setUp(self):
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
if not self.driver_wrapper.driver and not self.config_files.config_directory:
# By default config directory is located in test path
self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())
super(AppiumTestCase, self).setUp()
AppiumTestCase.app_strings = self.driver_wrapper.app_strings
示例5: driver_wrapper
def driver_wrapper():
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
driver_wrapper = DriverWrappersPool.get_default_wrapper()
driver_wrapper.driver = mock.MagicMock()
return driver_wrapper
示例6: setUp
def setUp(self):
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
# Create default wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
# Configure properties
config_files = ConfigFiles()
root_path = os.path.dirname(os.path.realpath(__file__))
config_files.set_config_directory(os.path.join(root_path, 'conf'))
config_files.set_output_directory(os.path.join(root_path, 'output'))
self.driver_wrapper.configure(tc_config_files=config_files)
示例7: setUp
def setUp(self):
# Configure logger and properties
if not isinstance(self, SeleniumTestCase):
# By default config directory is located in test path
if not self.config_files.config_directory:
self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
self.driver_wrapper.configure(False, self.config_files)
# Get config and logger instances
self.config = self.driver_wrapper.config
self.logger = logging.getLogger(__name__)
self.logger.info("Running new test: {0}".format(self.get_subclassmethod_name()))
示例8: setUp
def setUp(self):
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
config_files = ConfigFiles()
config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
config_files.set_output_directory(os.path.join(self.root_path, 'output'))
DriverWrappersPool.configure_common_directories(config_files)
self.driver_wrapper.configure_properties()
示例9: setUp
def setUp(self):
"""Create a new mock element and a new driver before each test"""
global mock_element
mock_element = mock.MagicMock(spec=WebElement)
mock_element.find_element.return_value = child_element
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
self.driver_wrapper.driver = mock.MagicMock()
示例10: __init__
def __init__(self):
if not DriverWrappersPool.is_empty():
# Copy config object and other properties from default driver
default_wrapper = DriverWrappersPool.get_default_wrapper()
self.config = default_wrapper.config.deepcopy()
self.logger = default_wrapper.logger
self.config_properties_filenames = default_wrapper.config_properties_filenames
self.config_log_filename = default_wrapper.config_log_filename
self.output_log_filename = default_wrapper.output_log_filename
self.visual_baseline_directory = default_wrapper.visual_baseline_directory
self.baseline_name = default_wrapper.baseline_name
# Create utils instance and add wrapper to the pool
self.utils = Utils(self)
DriverWrappersPool.add_wrapper(self)
示例11: setUp
def setUp(self):
"""Create a new mock element and a new driver before each test"""
# Create a mock element
self.mock_element = mock.MagicMock(spec=WebElement)
self.mock_element.find_element.return_value = child_element
self.mock_element.text = 'text value'
self.mock_element.get_attribute.return_value = 'input text value'
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
self.driver_wrapper.driver = mock.MagicMock()
示例12: tearDown
def tearDown(self):
# Call BasicTestCase tearDown
super(SeleniumTestCase, self).tearDown()
test_name = self.get_subclassmethod_name().replace('.', '_')
# Capture screenshot on error
if not self._test_passed:
DriverWrappersPool.capture_screenshots(test_name)
# Write Webdriver logs to files
self.utils.save_all_webdriver_logs(self.get_subclassmethod_name())
# Close browser and stop driver if it must not be reused
DriverWrappersPool.close_drivers_and_download_videos(test_name, self._test_passed, self.reuse_driver)
if not self.reuse_driver:
SeleniumTestCase.driver = None
示例13: driver_wrapper
def driver_wrapper():
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
new_driver_wrapper = DriverWrappersPool.get_default_wrapper()
# Configure wrapper
config_files = ConfigFiles()
root_path = os.path.dirname(os.path.realpath(__file__))
config_files.set_config_directory(os.path.join(root_path, 'conf'))
config_files.set_output_directory(os.path.join(root_path, 'output'))
config_files.set_config_log_filename('logging.conf')
new_driver_wrapper.configure(config_files)
return new_driver_wrapper
示例14: __init__
def __init__(self, driver_wrapper=None):
"""Initialize Utils instance
:param driver_wrapper: driver wrapper instance
"""
self.driver_wrapper = driver_wrapper if driver_wrapper else DriverWrappersPool.get_default_wrapper()
# Configure logger
self.logger = logging.getLogger(__name__)
示例15: driver_wrapper
def driver_wrapper():
# Create a mock element
global mock_element
mock_element = mock.MagicMock(spec=WebElement)
mock_element.find_element.return_value = child_element
mock_element.text = 'text value'
mock_element.get_attribute.return_value = 'input text value'
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
driver_wrapper = DriverWrappersPool.get_default_wrapper()
driver_wrapper.driver = mock.MagicMock()
return driver_wrapper