OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 | 6 |
7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
8 from telemetry.core import util | 8 from telemetry.core import util |
9 from telemetry.core import web_contents | 9 from telemetry.core import web_contents |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 self.ExecuteJavaScriptInContext(""" | 84 self.ExecuteJavaScriptInContext(""" |
85 document.getElementById('Email').value='%s'; | 85 document.getElementById('Email').value='%s'; |
86 document.getElementById('Passwd').value='%s'; | 86 document.getElementById('Passwd').value='%s'; |
87 document.getElementById('signIn').click();""" | 87 document.getElementById('signIn').click();""" |
88 % (username, password), | 88 % (username, password), |
89 gaia_iframe_context) | 89 gaia_iframe_context) |
90 | 90 |
91 def _NavigateWebViewLogin(self, username, password): | 91 def _NavigateWebViewLogin(self, username, password): |
92 """Logs into the webview-based GAIA screen""" | 92 """Logs into the webview-based GAIA screen""" |
93 self._NavigateWebViewEntry('identifierId', username) | 93 self._NavigateWebViewEntry('identifierId', username) |
| 94 self._GaiaWebViewContext().WaitForJavaScriptExpression( |
| 95 "document.getElementById('identifierId') == null", 20) |
| 96 |
94 self._NavigateWebViewEntry('password', password) | 97 self._NavigateWebViewEntry('password', password) |
| 98 util.WaitFor(lambda: self._GaiaWebViewContext() == None, 20) |
95 | 99 |
96 def _NavigateWebViewEntry(self, field, value): | 100 def _NavigateWebViewEntry(self, field, value): |
97 self._WaitForField(field) | 101 self._WaitForField(field) |
98 self._WaitForField('next') | 102 self._WaitForField('next') |
99 gaia_webview_context = self._GaiaWebViewContext() | 103 gaia_webview_context = self._GaiaWebViewContext() |
100 gaia_webview_context.EvaluateJavaScript(""" | 104 gaia_webview_context.EvaluateJavaScript(""" |
101 document.getElementById('%s').value='%s'; | 105 document.getElementById('%s').value='%s'; |
102 document.getElementById('next').click()""" | 106 document.getElementById('next').click()""" |
103 % (field, value)) | 107 % (field, value)) |
104 gaia_webview_context.WaitForJavaScriptExpression( | |
105 "document.getElementById('%s') == null" % field, 20) | |
106 | 108 |
107 def _WaitForField(self, field_id): | 109 def _WaitForField(self, field_id): |
108 gaia_webview_context = util.WaitFor(self._GaiaWebViewContext, 5) | 110 gaia_webview_context = util.WaitFor(self._GaiaWebViewContext, 5) |
109 util.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) | 111 util.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) |
110 gaia_webview_context.WaitForJavaScriptExpression( | 112 gaia_webview_context.WaitForJavaScriptExpression( |
111 "document.getElementById('%s') != null" % field_id, 20) | 113 "document.getElementById('%s') != null" % field_id, 20) |
OLD | NEW |