[autotest] Enable input and extensions with chromedriver.
Enables form filling via chromedriver by enabling xauthority
and setting the correct display variable for the chromedriver
server. Also adds a test for setting fields through chromedriver.
TEST=Ran the included test that sets input, loaded a component
extension.
BUG=chromium:321440
Change-Id: Ife548fdda770322a1b4c83e57750fbb829ac9097
Reviewed-on: https://chromium-review.googlesource.com/178722
Commit-Queue: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/client/common_lib/cros/chromedriver.py b/client/common_lib/cros/chromedriver.py
index f731b61..a118433 100644
--- a/client/common_lib/cros/chromedriver.py
+++ b/client/common_lib/cros/chromedriver.py
@@ -20,22 +20,29 @@
from autotest_lib.client.common_lib.cros import chrome
CHROMEDRIVER_EXE_PATH = '/usr/local/chromedriver/chromedriver'
+X_SERVER_DISPLAY = ':0'
+X_AUTHORITY = '/home/chronos/.Xauthority'
+
class chromedriver(object):
"""Wrapper class, a context manager type, for tests to use Chrome Driver."""
def __init__(self, extra_chrome_flags=[], subtract_extra_chrome_flags=[],
- *args, **kwargs):
+ extension_paths=[], is_component=True, *args, **kwargs):
"""Initialize.
@param extra_chrome_flags: Extra chrome flags to pass to chrome, if any.
@param subtract_extra_chrome_flags: Remove default flags passed to
chrome by chromedriver, if any.
+ @param extension_paths: A list of paths to unzipped extensions. Note
+ that paths to crx files won't work.
+ @param is_component: True if the manifest.json has a key.
"""
assert os.geteuid() == 0, 'Need superuser privileges'
# Log in with telemetry
- self._browser = chrome.Chrome().browser
+ self._browser = chrome.Chrome(extension_paths=extension_paths,
+ is_component=is_component).browser
# Start ChromeDriver server
self._server = chromedriver_server(CHROMEDRIVER_EXE_PATH)
@@ -94,6 +101,12 @@
port = utils.get_unused_port()
chromedriver_args = [exe_path, '--port=%d' % port]
+
+ # Chromedriver will look for an X server running on the display
+ # specified through the DISPLAY environment variable.
+ os.environ['DISPLAY'] = X_SERVER_DISPLAY
+ os.environ['XAUTHORITY'] = X_AUTHORITY
+
self.bg_job = utils.BgJob(chromedriver_args, stderr_level=logging.DEBUG)
self.url = 'http://localhost:%d' % port
if self.bg_job is None: