Testing that a value is set.

E

erinhouston

I am using winGuiAuto to test a program. I want to check that a
varible is set.

In the following code I am doing if(len(str(hwnd)) < 0) What is the
python way?

def clickNdSyncStopButton(hwnd=None):
.....if(hwnd == None):
.........hwnd = winGuiAuto.findTopWindow("NDSync")
.....if(len(str(hwnd)) < 0):
.........raise "Failed to find the NDSync Dialog"
.....StopButton = winGuiAuto.findControl(hwnd, "Stop",
"WindowsForms10.BUTTON.app3")
.....if(len(str(StopButton)) < 0):
.........raise "Failed to find the StopButton"
.....winGuiAuto.clickButton(StopButton)
 
F

Fredrik Lundh

I am using winGuiAuto to test a program. I want to check that a
varible is set.

In the following code I am doing if(len(str(hwnd)) < 0) What is the
python way?

you're expecting a string with negative length? that's pretty weird. what language
uses that mechanism to report errors?
def clickNdSyncStopButton(hwnd=None):
....if(hwnd == None):
........hwnd = winGuiAuto.findTopWindow("NDSync")

that's usually written:

if hwnd is None:
...
....if(len(str(hwnd)) < 0):
........raise "Failed to find the NDSync Dialog"

according to the winGuiAuto documentation, the findTopWindow function raises
an exception if it cannot find a window; maybe you should just ignore that, and let
the user code deal with that exception instead of your uncatchable string literals...

(rereading the chapter on exceptions in your favourite Python tutorial cannot hurt)

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top