Else part is not working

Asked by Muthumanikandan on 2017-07-28

Here is my code:

openApp("C:\Program Files (x86)\WarehouseManagementSystem\\WMS.exe")
type("1500894853016-1.png", "9992")
type("1500894876047-1.png","SA1" )
click("1500895066396-1.png")
click("1500895154711-1.png")
click(Pattern("dmspng-1.png").targetOffset(-190,-308))
wait(2)

if exists("1500901924611-1.png"):
    click("1500902007003-1.png")

else:
    click("1500902007007-1.png")

If part is working but else part not executing.Script stopped without any error, give me the code example for executing my case

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-07-28
Last reply:
2017-07-28
masuo (masuo-ohara) said : #1

You should confirm yourself that situation you think it did not work.
To use print is one way to confirm situation.
To use highlight() is one way to confirm where SikuliX found image.

m = exists("1500901924611-1.png")
print m
if m:
    print "if condition true"
    exists("1500902007003-1.png").highlight(2)
    click("1500902007003-1.png")

else:
    print "if condition false"
    exists("1500902007007-1.png").highlight(2)
    click("1500902007007-1.png")

Muthumanikandan (nmuthu1) said : #2

i dont want to print anywhere ,
the exact scenario is , if i connect scanner in my machine then i will not get any popup
suppose if i didnt connect scanner i will get popup
in this case i want my sikuli script to handle both cases , so kindly suggest me a code for this.

masuo (masuo-ohara) said : #3

I mean to output message to Sikuli IDE message area by "print".
So you don't need a printer or a scanner.

Muthumanikandan (nmuthu1) said : #4

Thnaks masuo for helping us, in this case i dont need output message. while executing my test case i am in need of scanner to scan barcodes.

 if i connect scanner in my machine then i will not get any popup
suppose if i didnt connect scanner i will get popup
in this case i want my sikuli script to handle both cases , so kindly suggest me a code for this.

masuo (masuo-ohara) said : #5

why don't you debug your codes?
you should confirm yourself that situation you think it did not work.

Muthumanikandan (nmuthu1) said : #6

I am a tester and i am very new to python, finally i found solution now the below code working fine.

doubleClick("1501306881166.png")
wait(2)
type(Pattern("1501306924449.png").targetOffset(-135,-51), "10002")
type(Pattern("1501307025253.png").targetOffset(-138,-1), "SA1")
click(Pattern("1501307079575.png").targetOffset(1,4))
wait(3)
click("1501307136462.png")
hover(Pattern("if dms.png").targetOffset(-245,-331))
click(Pattern("recdms.png").targetOffset(-240,-305))
wait(3)
m = exists("snippop.PNG")
if m:
 exists("snippop-1.PNG").highlight(2)
 click(Pattern("snippop-2.PNG").targetOffset(186,50))
 sleep(5)

else :
 #print "if condition false"
 exists("1501307454421.png").highlight(2)
 sleep(5)

click("1501307509048.png")
sleep(2)
openApp("notepad")

Can you help with this problem?

Provide an answer of your own, or ask Muthumanikandan for more information if necessary.

To post a message you must log in.