Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: telemetry/telemetry/internal/backends/chrome/oobe.py

Issue 2979923002: ChromeOS: add support for Gaia v2 API. (Closed)
Patch Set: Update after review. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/internal/backends/chrome/oobe.py
diff --git a/telemetry/telemetry/internal/backends/chrome/oobe.py b/telemetry/telemetry/internal/backends/chrome/oobe.py
index a39b6472bcd3bbee1679086f96ef6038856db5c7..5b233670b3df1891e7eb717836ef8024cbd18672 100644
--- a/telemetry/telemetry/internal/backends/chrome/oobe.py
+++ b/telemetry/telemetry/internal/backends/chrome/oobe.py
@@ -113,10 +113,19 @@ class Oobe(web_contents.WebContents):
self._WaitForField(field)
self._WaitForField(next_field)
gaia_webview_context = self._GaiaWebviewContext()
+ # This code supports both ChromeOS Gaia v1 and v2.
+ # In v2 'password' id is assigned to <DIV> element encapsulating
+ # unnamed <INPUT>. So this code will select the first <INPUT> element
+ # below the given field id in the DOM tree if field id is not attached
+ # to <INPUT>.
gaia_webview_context.EvaluateJavaScript("""
- document.getElementById({{ field }}).value= {{ value }};
- document.getElementById({{ next_field }}).click()""",
- field=field, value=value, next_field=next_field)
+ var field = document.getElementById({{ field }});
+ if (field.tagName != 'INPUT')
+ field = field.getElementsByTagName('INPUT')[0];
+
+ field.value= {{ value }};
+ document.getElementById({{ next_field }}).click();""",
+ field=field, value=value, next_field=next_field)
def _WaitForField(self, field):
gaia_webview_context = py_utils.WaitFor(self._GaiaWebviewContext, 5)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698