当我使用IE作为驱动程序运行此Selenium/WebDriver代码时,为什么python.exe会崩溃?

当我使用IE作为驱动程序运行此Selenium/WebDriver代码时,为什么python.exe会崩溃?,python,gmail-imap,Python,Gmail Imap,我在Windows7和Python2.7上安装了IE9。当我使用Firefox作为驱动程序时,这段代码运行得非常完美,但使用IE几秒钟后就会崩溃。我想知道它是否在while循环期间达到了高CPU状态?说到写好的while/wait循环,我是个书呆子 def text_from_gmail(username, password, to_user, pattern): gmail = PyGmail('imap.gmail.com') gmail.login(username, pa

我在Windows7和Python2.7上安装了IE9。当我使用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。我在driver.web.get(str(confirm_link))周围放了一个str(),现在它没有崩溃。

解决了。我想它是想转到一个格式错误的URL。我在driver.web.get(str(confirm_link))周围放了一个str(),它现在没有崩溃。findall返回一个列表,所以它试图转到[”而不是一个真正的URL。所以我返回链接[0],它工作得很好