selector: The element CSS selector.
"""
logging.info("action: Click %s" % selector)
+ self.WaitUntilDisplayed(selector)
element = self.driver.find_element_by_css_selector(selector)
element.click()
False otherwise.
"""
logging.info("action: ClickIfVisible %s" % selector)
+ self.WaitUntilDisplayed(selector)
try:
element = self.driver.find_element_by_css_selector(selector)
element.click()
selector: The element CSS selector.
"""
logging.info("action: Hover %s" % selector)
+ self.WaitUntilDisplayed(selector)
element = self.driver.find_element_by_css_selector(selector)
hover = ActionChains(self.driver).move_to_element(element)
hover.perform()
different than the one we expected.
"""
logging.info("action: FillPasswordInto %s" % selector)
-
+ self.WaitUntilDisplayed(selector)
password_element = self.driver.find_element_by_css_selector(selector)
# Chrome protects the password inputs and doesn't fill them until
# the user interacts with the page. To be sure that such thing has
- # happened we click on the password fields or one of its ancestors.
- element = password_element
- while True:
- try:
- element.click()
- break
- except Exception:
- try:
- element = element.parent
- except AttributeError:
- raise Exception("Error: unable to find a clickable element to "
- "release the password protection for the following website: %s \n"
- % (self.name))
-
+ # happened we perform |Keys.CONTROL| keypress.
+ action_chains = ActionChains(self.driver)
+ action_chains.key_down(Keys.CONTROL).key_up(Keys.CONTROL).perform()
if self.mode == self.Mode.AUTOFILLED:
autofilled_password = password_element.get_attribute("value")
if autofilled_password != self.password:
different that the one we expected.
"""
logging.info("action: FillUsernameInto %s" % selector)
+ self.WaitUntilDisplayed(selector)
username_element = self.driver.find_element_by_css_selector(selector)
if (self.mode == self.Mode.AUTOFILLED and not self.username_not_auto):
selector: The input CSS selector.
"""
logging.info("action: Submit %s" % selector)
+ self.WaitUntilDisplayed(selector)
element = self.driver.find_element_by_css_selector(selector)
element.submit()
def Logout(self):
"""Logout Method."""
- self.environment.ClearAllCookies()
# Tests
not like we expected or if the password is saved.
"""
logging.info("\nWrong Login Test for %s \n" % self.name)
- correct_password = self.password
- self.password = self.password + "1"
- self.LoginWhenNotAutofilled()
- self.password = correct_password
- self.Wait(2)
- self.environment.SwitchToInternals()
- self.environment.CheckForNewMessage(
- environment.MESSAGE_SAVE,
- False,
- "Error: password manager thinks that a login with wrong password was "
- "successful for the following website : %s \n" % self.name)
- self.environment.SwitchFromInternals()
+ try:
+ correct_password = self.password
+ self.password = self.password + "1"
+ self.LoginWhenNotAutofilled()
+ self.password = correct_password
+ self.Wait(2)
+ self.environment.SwitchToInternals()
+ self.environment.CheckForNewMessage(
+ environment.MESSAGE_SAVE,
+ False,
+ "Error: password manager thinks that a login with wrong password was "
+ "successful for the following website : %s \n" % self.name)
+ finally:
+ self.environment.SwitchFromInternals()
def SuccessfulLoginTest(self):
"""Does the successful login when the password is not expected to be
saved.
"""
logging.info("\nSuccessful Login Test for %s \n" % self.name)
- self.LoginWhenNotAutofilled()
- self.Wait(2)
- self.environment.SwitchToInternals()
- self.environment.CheckForNewMessage(
- environment.MESSAGE_SAVE,
- True,
- "Error: password manager hasn't detected a successful login for the "
- "following website : %s \n"
- % self.name)
- self.environment.SwitchFromInternals()
- self.Logout()
+ try:
+ self.LoginWhenNotAutofilled()
+ self.Wait(2)
+ self.environment.SwitchToInternals()
+ self.environment.CheckForNewMessage(
+ environment.MESSAGE_SAVE,
+ True,
+ "Error: password manager hasn't detected a successful login for the "
+ "following website : %s \n"
+ % self.name)
+ finally:
+ self.environment.SwitchFromInternals()
+ self.Logout()
def SuccessfulLoginWithAutofilledPasswordTest(self):
"""Does the successful login when the password is expected to be autofilled
"""
logging.info("\nSuccessful Login With Autofilled Password"
" Test %s \n" % self.name)
- self.LoginWhenAutofilled()
- self.Wait(2)
- self.environment.SwitchToInternals()
- self.environment.CheckForNewMessage(
- environment.MESSAGE_SAVE,
- True,
- "Error: password manager hasn't detected a successful login for the "
- "following website : %s \n"
- % self.name)
- self.environment.SwitchFromInternals()
- self.Logout()
+ try:
+ self.LoginWhenAutofilled()
+ self.Wait(2)
+ self.environment.SwitchToInternals()
+ self.environment.CheckForNewMessage(
+ environment.MESSAGE_SAVE,
+ True,
+ "Error: password manager hasn't detected a successful login for the "
+ "following website : %s \n"
+ % self.name)
+ finally:
+ self.environment.SwitchFromInternals()
+ self.Logout()
def PromptTest(self):
"""Does the prompt test: Tries to login with a wrong password and
password or is shown for a wrong one.
"""
logging.info("\nPrompt Test for %s \n" % self.name)
- correct_password = self.password
- self.password = self.password + "1"
- self.LoginWhenNotAutofilled()
- self.password = correct_password
- self.Wait(2)
- self.environment.SwitchToInternals()
- self.environment.CheckForNewMessage(
- environment.MESSAGE_ASK,
- False,
- "Error: password manager thinks that a login with wrong password was "
- "successful for the following website : %s \n" % self.name)
- self.environment.SwitchFromInternals()
-
- self.LoginWhenNotAutofilled()
- self.Wait(2)
- self.environment.SwitchToInternals()
- self.environment.CheckForNewMessage(
- environment.MESSAGE_ASK,
- True,
- "Error: password manager thinks that a login with wrong password was "
- "successful for the following website : %s \n" % self.name)
- self.environment.SwitchFromInternals()
+ try:
+ correct_password = self.password
+ self.password = self.password + "1"
+ self.LoginWhenNotAutofilled()
+ self.password = correct_password
+ self.Wait(2)
+ self.environment.SwitchToInternals()
+ self.environment.CheckForNewMessage(
+ environment.MESSAGE_ASK,
+ False,
+ "Error: password manager thinks that a login with wrong password was "
+ "successful for the following website : %s \n" % self.name)
+ self.environment.SwitchFromInternals()
+
+ self.LoginWhenNotAutofilled()
+ self.Wait(2)
+ self.environment.SwitchToInternals()
+ self.environment.CheckForNewMessage(
+ environment.MESSAGE_ASK,
+ True,
+ "Error: password manager hasn't detected a successful login for the "
+ "following website : %s \n" % self.name)
+ finally:
+ self.environment.SwitchFromInternals()