UnicodeEncodeError: 'ascii' codec can't encode character
${email} Wait For Email recipient=${recipient} subject=Активируйте учетную запись timeout=120
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
def check_email_subject(self, email_id, sub_text):
conn = imaplib.IMAP4_SSL('imap.gmail.com', 993)
conn.login('em...@gmail.com', 'qweasd!@#')
conn.select()
typ, data = conn.uid('fetch', email_id, '(BODY.PEEK[HEADER.FIELDS (SUBJECT)])')
for res in data:
if isinstance(res, tuple):
header = email.header.decode_header(str(res[1].strip()))
header_str = "".join([x[0].decode('utf-8').strip() if x[1] else re.sub("(^b\'|\')", "", str(x[0])) for x in header])
header_str = re.sub("Subject: ", "", header_str)
header_str = re.sub("(\\\\r|\\\\n|\')", "", header_str)
if sub_text != header_str.strip():
raise Exception(header_str+' was not '+sub_text)
conn.logout()
[(b"b'Subject: ", None), (b' R\xc3\xa9initialisez votre mot de passe', 'utf-8'), (b"'", None)]
b"b"Réinitialisez votre mot de passeb"" was not Réinitialisez votre mot de passe
def check_email_subject(self, email_id, sub_text): conn = imaplib.IMAP4_SSL('imap.gmail.com', 993) conn.login('em...@gmail.com', 'qweasd!@#') conn.select() typ, data = conn.uid('fetch', email_id, '(BODY.PEEK[HEADER.FIELDS (SUBJECT)])') for res in data: if isinstance(res, tuple):
#header = re.sub("Subject: ", "", res[1]) header = email.header.decode_header(res[1].decode('ascii').strip()) print (header)
header_str = "".join([x[0].decode('utf-8').strip() if x[1] else re.sub("(^b\'|\')", "", str(x[0])) for x in header])
print (header_str) print (header_str.encode('utf-8').decode('utf-8'))
header_str = re.sub("Subject: ", "", header_str)