Suppression for crbug/241044.
[chromium-blink-merge.git] / chrome / test / install_test / chrome_options.py
blob48b67687e1c503ef886a315f419fa1c03ed6db31
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Chrome-specific options for configuring a ChromeDriver instance."""
7 import base64
10 class ChromeOptions(object):
11 """Chrome-specific options for configuring a ChromeDriver instance."""
13 def __init__(self):
14 """Initialize ChromeOptions object."""
15 self._capabilities = {'chrome.switches': [], 'chrome.extensions': []}
17 def AddSwitch(self, switch):
18 """Add a switch to be passed to Chrome.
20 Args:
21 switch: String switch to be passed to Chrome.
22 """
23 self._capabilities['chrome.switches'].append(switch)
25 def AddExtension(self, extension):
26 """Add an extension to be loaded onto Chrome.
28 Args:
29 extension: String path to the extension to be loaded onto Chrome.
30 """
31 with open(extension, 'rb') as ext_file:
32 self._capabilities['chrome.extensions'].append(
33 base64.b64encode(ext_file.read()))
35 def SetUserDataDir(self, user_data_dir):
36 """Set the Chrome user data dir.
38 Args:
39 user_data_dir: String path to the profile directory.
40 """
41 self.AddSwitch('user-data-dir=%s' % user_data_dir)
43 def GetCapabilities(self):
44 """Returns a capabilities object suitable for using with ChromeDriver."""
45 return self._capabilities