为什么我的pywinauto代码在while语句中不断给出错误

时间:2013-02-14 16:24:12

标签: python while-loop pywinauto

我在第二次声明中尝试了不同的if语句无效,我一直收到错误,我不知道为什么。以下是代码以及回溯错误。感谢您的帮助!

import os
import time
from pywinauto import application
from SendKeys import SendKeys

start = time.clock()

while True:

    # Open the Update Tool
    app=application.Application()
    app.start_(r"C:\Program Files\... \File.exe")
    dlg=app.Update
    time.sleep(2)


    #Delete the last octet of the ip address
    app.dlg.edit0.SetEditText('')
    time.sleep(2)

    #Type the sim's last octet of the ip address
    app.dlg.edit0.TypeKeys('76')
    time.sleep(2)

    #Click the Connect Button
    app.dlg.Button4.Click()
    time.sleep(2)

    #Click Resources Management Tab
    app.dlg.ClickInput(button='left',coords=(263,50),double=False,wheel_dist=0)
    time.sleep(4)


    #select the version from combobox
    app.dlg.ComboBox.Select('release_02.0.1')
    time.sleep(2) 


    #Click the select all checkbox
    app.dlg.CheckBox.Check()
    time.sleep(2)

    #Click the Update button (update window)
    app.dlg.Update.Click()


    while app.dlg.Update.IsEnabled():
        t_time = time.clock() - start
        t_minutes = t_time / 60.0
        print t_time, 'seconds'
        if app.dlg.Update.WaitNot('visible'):
            break



    print '\n'
    print t_minutes, "minutes"
    time.sleep(2)

    #Click the Okay button to exit from the success dialog (This is a pop dialog, denoting that the update has finished)
    app.dlg.OKButton.Click()


    #Click Actual State Tab
    app.dlg.ClickInput(button='left',coords=(75,50),double=False,wheel_dist=0)
    time.sleep(5)    


    #Click the Disconnect Button
    app.dlg.Button3.Click()
    time.sleep(3)


    app.Kill_()
    tot_time = time.clock() - start
    print time.clock() - start, "seconds"
    time.sleep(5)


    if tot_time >= 600.0:
        break

这是追溯:

Traceback (most recent call last):
File "C:\Users\mike\Desktop\updte.py", line 51, in <module>
if app.dlg.Update.WaitNot('visible'):
File "C:\Python27\lib\site-packages\pywinauto\application.py", line 442, in WaitNot
"', '".join( wait_for_not.split() ) )
RuntimeError: Timed out while waiting for window (Button - 'Update') to not be in     'visible' state

0 个答案:

没有答案