6
6
import yaml
7
7
import simplejson
8
8
import pytest
9
-
9
+ import string
10
+ import random
10
11
11
12
def _rel_path (* args ):
12
13
"""Returns a path relative to config.py file's directory."""
@@ -103,6 +104,12 @@ def _get_firefox_profile():
103
104
)
104
105
return firefox_profile
105
106
107
+ def _get_chrome_profile ():
108
+ """Returns the Chrome profile directory to be used for the Chrome webdriver."""
109
+ seed = string .ascii_letters + string .digits
110
+ profile_hash = '' .join (random .choice (seed ) for x in range (6 ))
111
+ return '.org.chromium.Chromium.' + profile_hash
112
+
106
113
def get_browsers (capabilities_file_path = None ):
107
114
"""Returns a list of capabilities. Each item in the list will cause
108
115
the entire suite of tests to be re-run for a browser with those
@@ -138,17 +145,19 @@ def create_webdriver(command_executor, desired_capabilities):
138
145
BROWSER = "chrome"
139
146
desired_capabilities = DesiredCapabilities .CHROME .copy ()
140
147
desired_capabilities .update (_capabilities )
148
+ options = chrome .options .Options ()
149
+ browser_profile_path = os .path .join ('/tmp' , _get_chrome_profile ())
150
+ options .add_argument ('--user-data-dir=' + browser_profile_path )
141
151
if desired_capabilities ["version" ] > CHROME_EXT_MAX_CHROME_VERSION :
142
152
# Add new chrome extension to capabilities.
143
- options = chrome .options .Options ()
144
153
options .add_extension (os .path .join (_EXTENSIONS_DIR , _CHROME_APP_FNAME ))
145
154
options .add_argument ("--user-agent=" + TESTS_USER_AGENT_CHROME )
146
- desired_capabilities .update (options .to_capabilities ())
147
- desired_capabilities .update (_capabilities )
148
155
else :
149
156
raise ValueError ("The testing suite only supports Chrome versions greater than v%d, "
150
157
"but v%d was specified. Please specify a higher version number."
151
158
% (CHROME_EXT_MAX_CHROME_VERSION , desired_capabilities ["version" ]))
159
+ desired_capabilities .update (options .to_capabilities ())
160
+ desired_capabilities .update (_capabilities )
152
161
153
162
elif browser_name == "firefox" :
154
163
desired_capabilities = DesiredCapabilities .FIREFOX .copy ()
@@ -159,6 +168,7 @@ def create_webdriver(command_executor, desired_capabilities):
159
168
desired_capabilities ["firefox_profile" ] = browser_profile .update_preferences ()
160
169
else :
161
170
raise ValueError ("Invalid webdriver %s (only chrome and firefox are supported)" % browser_name )
171
+
162
172
return {
163
173
'driver' : webdriver .Remote (
164
174
command_executor = command_executor ,
0 commit comments