本文整理汇总了Python中toolium.config_driver.ConfigDriver._create_chrome_options方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDriver._create_chrome_options方法的具体用法?Python ConfigDriver._create_chrome_options怎么用?Python ConfigDriver._create_chrome_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toolium.config_driver.ConfigDriver
的用法示例。
在下文中一共展示了ConfigDriver._create_chrome_options方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_chrome_options_headless
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import _create_chrome_options [as 别名]
def test_create_chrome_options_headless(webdriver_mock, config):
config.set('Driver', 'headless', 'true')
config_driver = ConfigDriver(config)
config_driver._create_chrome_options()
webdriver_mock.ChromeOptions.assert_called_once_with()
if os.name == 'nt':
webdriver_mock.ChromeOptions().add_argument.assert_has_calls([mock.call('--headless'),
mock.call('--disable-gpu')])
else:
webdriver_mock.ChromeOptions().add_argument.assert_called_once_with('--headless')
示例2: test_create_chrome_options
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import _create_chrome_options [as 别名]
def test_create_chrome_options(webdriver_mock, config):
config.add_section('ChromePreferences')
config.set('ChromePreferences', 'download.default_directory', '/tmp')
config.add_section('ChromeMobileEmulation')
config.set('ChromeMobileEmulation', 'deviceName', 'Google Nexus 5')
config.add_section('ChromeArguments')
config.set('ChromeArguments', 'lang', 'es')
config_driver = ConfigDriver(config)
config_driver._create_chrome_options()
webdriver_mock.ChromeOptions.assert_called_once_with()
webdriver_mock.ChromeOptions().add_experimental_option.assert_has_calls(
[mock.call('prefs', {'download.default_directory': '/tmp'}),
mock.call('mobileEmulation', {'deviceName': 'Google Nexus 5'})])
webdriver_mock.ChromeOptions().add_argument.assert_called_once_with('lang=es')
示例3: test_create_local_driver_chrome
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import _create_chrome_options [as 别名]
def test_create_local_driver_chrome(webdriver_mock, config):
config.set('Driver', 'type', 'chrome')
config.set('Driver', 'chrome_driver_path', '/tmp/driver')
config_driver = ConfigDriver(config)
config_driver._create_chrome_options = lambda: 'chrome options'
config_driver._create_local_driver()
webdriver_mock.Chrome.assert_called_once_with('/tmp/driver', desired_capabilities=DesiredCapabilities.CHROME,
chrome_options='chrome options')
示例4: test_create_remote_driver_chrome_old_selenium
# 需要导入模块: from toolium.config_driver import ConfigDriver [as 别名]
# 或者: from toolium.config_driver.ConfigDriver import _create_chrome_options [as 别名]
def test_create_remote_driver_chrome_old_selenium(webdriver_mock, config):
config.set('Server', 'host', '10.20.30.40')
config.set('Server', 'port', '5555')
config.set('Driver', 'type', 'chrome')
config_driver = ConfigDriver(config)
# Chrome options mock
chrome_options = mock.MagicMock()
chrome_options.to_capabilities.return_value = {'chromeOptions': 'chrome options'}
config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)
config_driver._create_remote_driver()
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['chromeOptions'] = 'chrome options'
webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
desired_capabilities=capabilities)