简体   繁体   English

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

[英]Why does python.exe crash when I run this Selenium/WebDriver code using IE as the driver?

I've got IE 9 on Windows 7 and Python 2.7. 我在Windows 7和Python 2.7上安装了IE 9。 This code runs perfectly when I use Firefox for the driver, but with IE it crashes after a few seconds. 当我使用Firefox作为驱动程序时,此代码可以完美运行,但是使用IE时,它在几秒钟后崩溃。 I wonder if it's hitting a high CPU state during the while loop? 我想知道在while循环期间是否达到了很高的CPU状态? I am a noob when it comes to writing good while/wait loops. 对于编写良好的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

It was trying to go to a malformed URL I think. 我认为它试图转到格式错误的URL。 I put a str() around it driver.web.get(str(confirm_link)) and it's not crashing now. 我在它周围放了一个str()driver.web.get(str(confirm_link)),它现在没有崩溃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在python.exe中运行时,Python代码不同 - Python code different when run in python.exe 我无法使用 python.exe 运行 python 程序 - I'm unable to run a python program using python.exe 为什么Python.exe停止响应? - Why Does Python.exe Stop Responding? 为什么 Windows 看不到 python.exe? - Why does Windows not see python.exe? python.exe 在我运行 python **.py 时崩溃,来自 windows ZDFFF0A7FA1A55C8C1A4966C19FDA445 - python.exe was crashed when I run python **.py from windows cmd 从 VBA 运行 Python 脚本没有任何反应,但是当我从 python.exe 运行它时,它起作用了 - Running Python script from VBA nothing happens, but when I run it from python.exe, it works 当 python.exe 设置为“以管理员身份运行”时,在 Windows 中运行 python 脚本会给出“无法使用...创建进程” - Running a python script in Windows gives "Unable to Create Process Using ..." when python.exe set to 'run as administrator' 我已经正确设置了 PyCharm 解释器,但是当运行代码时,它显示在运行 window PyCharm 使用另一个 Z23EEEB4347BDD25DDAZBexe 之前使用9EEE73BDD25DDAZBexe。 - I have set PyCharm interpreter right but when run the code, it shows in the run window PyCharm uses another python.exe I used before 当我调用“sess.run()”时,“python.exe”程序引发错误 - The "python.exe" program raises an error when I call "sess.run()" 任何人都知道为什么我的文件用 Python.exe 打开? - Anyone knows why does my file opens with Python.exe?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM