Commit f1be3c26 authored by melandory's avatar melandory Committed by Commit bot

[Password manager tests automation] Fixed buzzfeed.

Fixes buzzfeed by introducing password_not_auto parameter.

BUG=369521
R=vabr@chromium.org

Review URL: https://codereview.chromium.org/1138353003

Cr-Commit-Position: refs/heads/master@{#330502}
parent f0d41ff4
...@@ -449,7 +449,9 @@ all_tests = { ...@@ -449,7 +449,9 @@ all_tests = {
"amazon": Amazon("amazon"), # Bug not reproducible without test. "amazon": Amazon("amazon"), # Bug not reproducible without test.
"ask": Ask("ask"), # Password not saved. "ask": Ask("ask"), # Password not saved.
"baidu": Baidu("baidu"), # Password not saved. "baidu": Baidu("baidu"), # Password not saved.
"buzzfeed": Buzzfeed("buzzfeed"), "buzzfeed": Buzzfeed("buzzfeed",
username_not_auto=True,
password_not_auto=True),
"cnn": Cnn("cnn"), # http://crbug.com/368690 "cnn": Cnn("cnn"), # http://crbug.com/368690
"craigslist": Craigslist("craigslist"), # Too many failed logins per time. "craigslist": Craigslist("craigslist"), # Too many failed logins per time.
"dailymotion": Dailymotion("dailymotion"), # Crashes. "dailymotion": Dailymotion("dailymotion"), # Crashes.
......
...@@ -30,18 +30,21 @@ class WebsiteTest: ...@@ -30,18 +30,21 @@ class WebsiteTest:
# interaction. # interaction.
MAX_WAIT_TIME_IN_SECONDS = 200 MAX_WAIT_TIME_IN_SECONDS = 200
def __init__(self, name, username_not_auto=False): def __init__(self, name, username_not_auto=False, password_not_auto=False):
"""Creates a new WebsiteTest. """Creates a new WebsiteTest.
Args: Args:
name: The website name, identifying it in the test results. name: The website name, identifying it in the test results.
username_not_auto: Expect that the tested website fills username field username_not_auto: Expect that the tested website fills username field
on load, and Chrome cannot autofill in that case. on load, and Chrome cannot autofill in that case.
password_not_auto: Expect that the tested website fills password field
on load, and Chrome cannot autofill in that case.
""" """
self.name = name self.name = name
self.username = None self.username = None
self.password = None self.password = None
self.username_not_auto = username_not_auto self.username_not_auto = username_not_auto
self.password_not_auto = password_not_auto
# Specify, whether it is expected that credentials get autofilled. # Specify, whether it is expected that credentials get autofilled.
self.autofill_expectation = WebsiteTest.NOT_AUTOFILLED self.autofill_expectation = WebsiteTest.NOT_AUTOFILLED
...@@ -195,7 +198,9 @@ class WebsiteTest: ...@@ -195,7 +198,9 @@ class WebsiteTest:
Depending on self.autofill_expectation, this either checks that the Depending on self.autofill_expectation, this either checks that the
element already has the password autofilled, or checks that the value element already has the password autofilled, or checks that the value
is empty and replaces it with the password. is empty and replaces it with the password. If self.password_not_auto
is true, it skips the checks and just overwrites the value with the
password.
Args: Args:
selector: The CSS selector for the filled element. selector: The CSS selector for the filled element.
...@@ -215,15 +220,18 @@ class WebsiteTest: ...@@ -215,15 +220,18 @@ class WebsiteTest:
action_chains.key_down(Keys.CONTROL).key_up(Keys.CONTROL).perform() action_chains.key_down(Keys.CONTROL).key_up(Keys.CONTROL).perform()
self.Wait(2) # TODO(vabr): Detect when autofill finished. self.Wait(2) # TODO(vabr): Detect when autofill finished.
if self.autofill_expectation == WebsiteTest.AUTOFILLED: if not self.password_not_auto:
if password_element.get_attribute("value") != self.password: if self.autofill_expectation == WebsiteTest.AUTOFILLED:
raise Exception("Error: autofilled password is different from the saved" if password_element.get_attribute("value") != self.password:
" one on website: %s" % self.name) raise Exception("Error: autofilled password is different from the"
elif self.autofill_expectation == WebsiteTest.NOT_AUTOFILLED: "saved one on website: %s" % self.name)
if password_element.get_attribute("value"): elif self.autofill_expectation == WebsiteTest.NOT_AUTOFILLED:
raise Exception("Error: password value unexpectedly not empty on" if password_element.get_attribute("value"):
"website: %s" % self.name) raise Exception("Error: password value unexpectedly not empty on"
password_element.send_keys(self.password) "website: %s" % self.name)
password_element.clear()
password_element.send_keys(self.password)
def FillUsernameInto(self, selector): def FillUsernameInto(self, selector):
"""Ensures that the selected element's value is the saved username. """Ensures that the selected element's value is the saved username.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment