[英]Why does python.exe crash when I run this Selenium/WebDriver code using IE as the driver?
我在Windows 7和Python 2.7上安裝了IE 9。 當我使用Firefox作為驅動程序時,此代碼可以完美運行,但是使用IE時,它在幾秒鍾后崩潰。 我想知道在while循環期間是否達到了很高的CPU狀態? 對於編寫良好的while / wait循環,我是一個菜鳥。
def text_from_gmail(username, password, to_user, pattern):
gmail = PyGmail('imap.gmail.com')
gmail.login(username, password)
#find the id of the confirmation message
sec_waiting = 0
msg_uid = ['']
sleep_period = 10 # seconds to wait between Gmail searches
while msg_uid == ['']: # wait until message list from server isn't empty
gmail.m.select('[Gmail]/All Mail')
resp, msg_uid = gmail.m.search(None, 'To', to_user)
if(msg_uid != ['']):
break # don't sleep if the message was found quickly
time.sleep(sleep_period) # pause between checks
sec_waiting += sleep_period
if sec_waiting >= 300: # 5 minute timeout
assert False # fail the test if timeout elapses
# extract the confirmation link from the message
# it's a multi-part MIME, so we have to grab the attachment and decode it
typ, msg_data = gmail.m.fetch(msg_uid[0], '(RFC822)')
gmail.logout()
email_body = msg_data[0][1]
mail = email.message_from_string(email_body)
body = ""
for part in mail.walk():
if(part.get_content_type() == 'text/plain'):
body = part.get_payload(decode=True)
link = re.findall(pattern, body)
return link
我認為它試圖轉到格式錯誤的URL。 我在它周圍放了一個str()driver.web.get(str(confirm_link)),它現在沒有崩潰。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.