本文整理汇总了Python中toolium.config_driver.ConfigDriver.set_window_size方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDriver.set_window_size方法的具体用法?Python ConfigDriver.set_window_size怎么用?Python ConfigDriver.set_window_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toolium.config_driver.ConfigDriver
的用法示例。
在下文中一共展示了ConfigDriver.set_window_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DriverWrapper
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import set_window_size [as 别名]
#.........这里部分代码省略.........
def connect(self, maximize=True):
"""Set up the selenium driver and connect to the server
:param maximize: True if the driver should be maximized
:returns: selenium driver
"""
if not self.config.get('Driver', 'type') or self.config.get('Driver', 'type') in ['api', 'no_driver']:
return None
self.driver = ConfigDriver(self.config).create_driver()
# Save session id and remote node to download video after the test execution
self.session_id = self.driver.session_id
self.remote_node = self.utils.get_remote_node()
self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)
# Save app_strings in mobile tests
if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',
'appium_app_strings'):
self.app_strings = self.driver.app_strings()
if self.is_maximizable():
# Bounds and screen
bounds_x, bounds_y = self.get_config_window_bounds()
self.driver.set_window_position(bounds_x, bounds_y)
self.logger.debug('Window bounds: %s x %s', bounds_x, bounds_y)
# Maximize browser
if maximize:
# Set window size or maximize
window_width = self.config.get_optional('Driver', 'window_width')
window_height = self.config.get_optional('Driver', 'window_height')
if window_width and window_height:
self.driver.set_window_size(window_width, window_height)
else:
self.driver.maximize_window()
# Log window size
window_size = self.utils.get_window_size()
self.logger.debug('Window size: %s x %s', window_size['width'], window_size['height'])
# Update baseline
self.update_visual_baseline()
# Discard previous logcat logs
self.utils.discard_logcat_logs()
# Set implicitly wait timeout
self.utils.set_implicitly_wait()
return self.driver
def get_config_window_bounds(self):
"""Reads bounds from config and, if monitor is specified, modify the values to match with the specified monitor
:return: coords X and Y where set the browser window.
"""
bounds_x = int(self.config.get_optional('Driver', 'bounds_x') or 0)
bounds_y = int(self.config.get_optional('Driver', 'bounds_y') or 0)
monitor_index = int(self.config.get_optional('Driver', 'monitor') or -1)
if monitor_index > -1:
try:
monitor = screeninfo.get_monitors()[monitor_index]
bounds_x += monitor.x
bounds_y += monitor.y
示例2: DriverWrapper
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import set_window_size [as 别名]
#.........这里部分代码省略.........
# Configure visual directories
if is_selenium_test:
driver_info = self.config.get('Driver', 'type').replace('-', '_')
DriverWrappersPool.configure_visual_directories(driver_info)
self.configure_visual_baseline()
def connect(self, maximize=True):
"""Set up the selenium driver and connect to the server
:param maximize: True if the driver should be maximized
:returns: selenium driver
"""
if not self.config.get('Driver', 'type'):
return None
self.driver = ConfigDriver(self.config).create_driver()
# Save session id and remote node to download video after the test execution
self.session_id = self.driver.session_id
self.remote_node = self.utils.get_remote_node()
self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)
# Save app_strings in mobile tests
if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',
'appium_app_strings'):
self.app_strings = self.driver.app_strings()
# Maximize browser
if maximize and self.is_maximizable():
# Set window size or maximize
window_width = self.config.get_optional('Driver', 'window_width')
window_height = self.config.get_optional('Driver', 'window_height')
if window_width and window_height:
self.driver.set_window_size(window_width, window_height)
else:
self.driver.maximize_window()
# Log window size
window_size = self.utils.get_window_size()
self.logger.debug('Window size: {} x {}'.format(window_size['width'], window_size['height']))
# Update baseline
self.update_visual_baseline()
# Discard previous logcat logs
self.utils.discard_logcat_logs()
return self.driver
def is_android_test(self):
"""Check if actual test must be executed in an Android mobile
:returns: true if test must be executed in an Android mobile
"""
driver_name = self.config.get('Driver', 'type').split('-')[0]
return driver_name == 'android'
def is_ios_test(self):
"""Check if actual test must be executed in an iOS mobile
:returns: true if test must be executed in an iOS mobile
"""
driver_name = self.config.get('Driver', 'type').split('-')[0]
return driver_name in ('ios', 'iphone')
def is_mobile_test(self):