def start_headless(self):
"""Headless Chrome initiator."""
print('Start headless browser')
option_set = options.Options()
option_set.add_arguments("test-type")
option_set.add_arguments("start-maximized")
option_set.add_arguments("--js-flags=--expose-gc")
option_set.add_arguments("--enable-precise-memory-info")
option_set.add_argument('headless')
option_set.add_argument('disable-notifications')
option_set.add_argument('disable-gpu')
option_set.add_argument('disable-infobars')
option_set.add_arguments("--disable-default-apps")
option_set.add_arguments("test-type=browser")
option_set.add_experimental_option(
'prefs', {
'credentials_enable_service': False,
'profile': {
'password_manager_enabled': False
}
}
)
option_set.binary_location = os.getenv(
'CHROME_CANARY',
'/Applications/Google Chrome Canary.app' +
'/Contents/MacOS/Google Chrome Canary'
)
webdriver_service = service.Service(
os.getenv(
'CHROMEDRIVER',
'/Applications/chromedriver'
)
)
webdriver_service.start()
print('Service started; returning Remote webdriver')
return webdriver.Remote(
webdriver_service.service_url,
option_set.to_capabilities()
)
评论列表
文章目录