blob: c9055ee83dcd1099bd152952265bdebd84671198 [file] [log] [blame]
Dennis Jeffreydffc0bd2013-05-03 13:24:31 -07001# Copyright (c) 2013 The Chromium OS 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.
4
5"""Telemetry-based Chrome automation functions."""
6
7from telemetry.core import browser_finder, browser_options
8
9
10# The following constant is the name of the logged-in user that is specified
11# by the Telemetry chromeOS login extension
12# (chromium/src/tools/telemetry/telemetry/core/chrome/chromeos_login_ext).
13# The value here must match what is specified in that login extension.
14LOGIN_USER = 'test@test.test'
15
16
17def login():
18 """Logs into Chrome.
19
20 Wrapping this within a Python with/as construct will take care of
21 automatically logging into Chrome at the start and logging out of Chrome
22 at the end, e.g.:
23
24 with chrome.login() as chrome_obj:
25 do_test() # Will be logged in for this.
26 # Logged out at this point.
27
28 @return A Telemetry Browser object supporting context management.
29 """
30 default_options = browser_options.BrowserOptions()
31 default_options.browser_type = 'system'
32 browser_to_create = browser_finder.FindBrowser(default_options)
33 return browser_to_create.Create()