Skip to content

Commit 0b0221e

Browse files
committed
Changing Firefox user agent to custom UA string,
in order to be able to identify the selenium tests browser in metrics.
1 parent 25f2009 commit 0b0221e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

codebender_testing/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def jsondump(data):
7979
'LOCATE_ELEMENT': 30
8080
}
8181

82+
TESTS_USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
83+
8284
# Set up Selenium Webdrivers to be used for selenium tests
8385
def _get_firefox_profile():
8486
"""Returns the Firefox profile to be used for the FF webdriver.
@@ -147,6 +149,8 @@ def create_webdriver(command_executor, desired_capabilities):
147149
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
148150
desired_capabilities.update(_capabilities)
149151
browser_profile = _get_firefox_profile()
152+
browser_profile.set_preference("general.useragent.override", TESTS_USER_AGENT)
153+
desired_capabilities["firefox_profile"] = browser_profile.update_preferences()
150154
else:
151155
raise ValueError("Invalid webdriver %s (only chrome and firefox are supported)" % browser_name)
152156
return webdriver.Remote(

0 commit comments

Comments
 (0)