code: def _login(self, max_tries=2):
      
  
      if not self.current_url.startswith(_KindleCloudReaderBrowser._SIGNIN_URL):
        raise BrowserError(
            'Current url "%s" is not a signin url ("%s")' %
            (self.current_url, _KindleCloudReaderBrowser._SIGNIN_URL))
  
      email_field_loaded = lambda br: br.find_elements_by_id('ap_email')
      self._wait().until(email_field_loaded)
      tries = 0
      while tries < max_tries:
        # Enter the username
        email_elem = self.find_element_by_id('ap_email')
        email_elem.clear()
        email_elem.send_keys(self._uname)
  
        # Enter the password
        pword_elem = self.find_element_by_id('ap_password')
        pword_elem.clear()
        pword_elem.send_keys(self._pword)
  
        def creds_entered(_):
          """Returns whether the credentials were properly entered."""
  
          email_ok = email_elem.get_attribute('value') == self._uname
          pword_ok = pword_elem.get_attribute('value') == self._pword
          return email_ok and pword_ok
  
        kcr_page_loaded = lambda br: br.title == u'Kindle Cloud Reader'
        try:
          self._wait(5).until(creds_entered)
          self.find_element_by_id('signInSubmit-input').click()
          self._wait(5).until(kcr_page_loaded)
        except TimeoutException:
          tries += 1
        else:
          return
  
      raise LoginError
docs: Logs in to Kindle Cloud Reader.
  
      Args:
        max_tries: The maximum number of login attempts that will be made.
  
      Raises:
        BrowserError: If method called when browser not at a signin URL.
        LoginError: If login unsuccessful after `max_tries` attempts.