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

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

Issue 11943014: Fix facebook_credentials_backend_unittest on android-content-shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/form_based_credentials_backend.py
diff --git a/tools/telemetry/telemetry/form_based_credentials_backend.py b/tools/telemetry/telemetry/form_based_credentials_backend.py
index 2769eba4fcc2cdbf74e63435c9ce28b974f42f30..368a80ad4098e7fd0022d5ef1884982bfbede933 100644
--- a/tools/telemetry/telemetry/form_based_credentials_backend.py
+++ b/tools/telemetry/telemetry/form_based_credentials_backend.py
@@ -8,16 +8,11 @@ import telemetry
from telemetry import util
-def _IsAlreadyLoggedIn(already_logged_in_element_id, tab):
- return tab.EvaluateJavaScript(
- 'document.getElementById("%s")!== null' % \
- already_logged_in_element_id)
-
-def _WaitForLoginFormToLoad(login_form_id, already_logged_in_element_id, tab):
+def _WaitForLoginFormToLoad(backend, login_form_id, tab):
def IsFormLoadedOrAlreadyLoggedIn():
return tab.EvaluateJavaScript(
'document.querySelector("#%s")!== null' % login_form_id) or \
- _IsAlreadyLoggedIn(already_logged_in_element_id, tab)
+ backend.IsAlreadyLoggedIn(tab)
# Wait until the form is submitted and the page completes loading.
util.WaitFor(lambda: IsFormLoadedOrAlreadyLoggedIn(), # pylint: disable=W0108
@@ -38,6 +33,9 @@ class FormBasedCredentialsBackend(object):
def __init__(self):
self._logged_in = False
+ def IsAlreadyLoggedIn(self, tab):
+ raise NotImplementedError()
+
@property
def credentials_type(self):
raise NotImplementedError()
@@ -55,10 +53,6 @@ class FormBasedCredentialsBackend(object):
raise NotImplementedError()
@property
- def already_logged_in_element_id(self):
- raise NotImplementedError()
-
- @property
def password_input_id(self):
raise NotImplementedError()
@@ -90,21 +84,19 @@ class FormBasedCredentialsBackend(object):
try:
logging.info('Loading %s...', self.url)
tab.Navigate(self.url)
- _WaitForLoginFormToLoad(self.login_form_id,
- self.already_logged_in_element_id,
- tab)
+ _WaitForLoginFormToLoad(self, self.login_form_id, tab)
- if _IsAlreadyLoggedIn(self.already_logged_in_element_id, tab):
+ if self.IsAlreadyLoggedIn(tab):
self._logged_in = True
return True
tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
logging.info('Loaded page: %s', self.url)
- email_id = 'document.getElementById("%s").value = "%s"; ' % (
- self.login_input_id, config['username'])
- password = 'document.getElementById("%s").value = "%s"; ' % (
- self.password_input_id, config['password'])
+ 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"; ' % (
+ self.login_form_id, self.password_input_id, config['password'])
tab.ExecuteJavaScript(email_id)
tab.ExecuteJavaScript(password)
« no previous file with comments | « tools/telemetry/telemetry/facebook_credentials_backend.py ('k') | tools/telemetry/telemetry/google_credentials_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698