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

Unified Diff: tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py

Issue 485743002: Add support for codepen to form_based_credentials_background (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo tracing timeout change Created 6 years, 4 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
Index: tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py b/tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py
index bb32f32251a3489a3053af0629642ad7fd8b00a9..cf3c9fdcbf3139873f83271f545159f6b09afa64 100644
--- a/tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py
+++ b/tools/telemetry/telemetry/core/backends/form_based_credentials_backend.py
@@ -15,9 +15,14 @@ def _WaitForLoginFormToLoad(backend, login_form_id, tab):
# Wait until the form is submitted and the page completes loading.
util.WaitFor(IsFormLoadedOrAlreadyLoggedIn, 60)
-def _SubmitFormAndWait(form_id, tab):
- tab.ExecuteJavaScript(
- 'document.getElementById("%s").submit();' % form_id)
+def _SubmitFormAndWait(form_id, button_id, tab):
+ if button_id:
+ tab.ExecuteJavaScript('setTimeout(function() {'
+ ' document.getElementById("%s").click();'
+ '}, 1000);' % button_id)
tonyg 2014/08/20 17:37:17 Is the timeout necessary in addition to the submit
sullivan 2014/08/21 21:55:23 Yes, it's necessary. I get an error message with a
+ else:
+ tab.ExecuteJavaScript(
+ 'document.getElementById("%s").submit();' % form_id)
def FinishedLoading():
return not tab.EvaluateJavaScript(
@@ -46,6 +51,11 @@ class FormBasedCredentialsBackend(object):
raise NotImplementedError()
@property
+ def login_button_id(self):
+ """Some sites (like codepen) have a button to click to log in."""
+ return None
+
+ @property
def login_input_id(self):
raise NotImplementedError()
@@ -95,14 +105,14 @@ class FormBasedCredentialsBackend(object):
tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
tonyg 2014/08/20 17:37:17 Does changing this to Complete instead of Interact
sullivan 2014/08/21 21:55:23 No, but I changed it anyway, since it seems like i
logging.info('Loaded page: %s', url)
- email_id = 'document.querySelector("#%s").%s.value = "%s"; ' % (
+ email_id = 'document.querySelector("#%s #%s").value = "%s"; ' % (
self.login_form_id, self.login_input_id, config['username'])
- password = 'document.querySelector("#%s").%s.value = "%s"; ' % (
+ password = 'document.querySelector("#%s #%s").value = "%s"; ' % (
self.login_form_id, self.password_input_id, config['password'])
tab.ExecuteJavaScript(email_id)
tab.ExecuteJavaScript(password)
- _SubmitFormAndWait(self.login_form_id, tab)
+ _SubmitFormAndWait(self.login_form_id, self.login_button_id, tab)
self._logged_in = True
return True

Powered by Google App Engine
This is Rietveld 408576698