Problem With For loop

Asked by Sathyamoorthy

Hello,

I am trying to do some several step [Adding VM disk continously] using for loop. But the loop is not iterating at all.
Here i am pasting the code
if (ndisk > 1):
    ndisk = int(ndisk) - 1
    for i in range(int(ndisk)):
        switchApp("New Virtual Machine - Virtual Machine properties")
        click("1343153484832.png")
        switchApp("Add Hardware")
        wait(1.5)
        click("HardDisk.png")
        click("1343145523513.png")
        click(Pattern("7Createanewv.png").targetOffset(-67,-2))
        click("Next-4.png")
        doubleClick(Pattern("IFDiskSize.png").targetOffset(28,0))
        type(d[i+1])
        click("Next-5.png")
        click("Next-6.png")
        click("Finish.png")

Please someone help me to do comeout of this problem

Thanks,
V.Sathyamoorthy

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#1

Copying the error message...

[log] App.focus New Virtual Machine - Virtual Machine properties(0) #0
[error] App.focus failed: New Virtual Machine - Virtual Machine properties not found

[error] Stopped
[error] An error occurs at line 53
[error] Error message: Traceback (most recent call last):
 File "C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py", line 53, in
 click("1343153484832.png")
 Line 67, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py

 at org.sikuli.script.Region.handleFindFailed(Region.java:420)
at org.sikuli.script.Region.wait(Region.java:511)
at org.python.proxies.sikuli.Region$Region$0.super__wait(Unknown Source)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

org.sikuli.script.FindFailed: FindFailed: can not find 1343153484832.png on the screen.
 Line 67, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#2

Copying the error message...

[log] App.focus New Virtual Machine - Virtual Machine properties(0) #0
[error] App.focus failed: New Virtual Machine - Virtual Machine properties not found

[error] Stopped
[error] An error occurs at line 53
[error] Error message: Traceback (most recent call last):
 File "C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py", line 53, in
 click("1343153484832.png")
 Line 67, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py

 at org.sikuli.script.Region.handleFindFailed(Region.java:420)
at org.sikuli.script.Region.wait(Region.java:511)
at org.python.proxies.sikuli.Region$Region$0.super__wait(Unknown Source)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

org.sikuli.script.FindFailed: FindFailed: can not find 1343153484832.png on the screen.
 Line 67, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp2265980759870165025.py

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#3

Sorry i unfortunately clsoed ....Opening the issue

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#4

Hi Guys,

The forloop goes first time and when comes to second iteration, the following message i am getting ,

[error] Stopped
[error] An error occurs at line 52
[error] Error message: Traceback (most recent call last):
 File "C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp4695093255318112514.py", line 52, in
 click("1343153484832.png")
 Line 65, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp4695093255318112514.py

 at org.sikuli.script.Region.handleFindFailed(Region.java:420)
at org.sikuli.script.Region.wait(Region.java:511)
at org.python.proxies.sikuli.Region$Region$0.super__wait(Unknown Source)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

org.sikuli.script.FindFailed: FindFailed: can not find 1343153484832.png on the screen.
 Line 65, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp4695093255318112514.py

The line number 52 is loop starting point.

please help me to sort otu this probelm

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#5

I am also pasting my complete code here

popup("... NW_OSSR Automation process ...")
name = input("Enter ESX IP \n [Where to create VM for OSSR]")
vname = input("Enter the VM name \n [Which is not exists in ESX host]")
ndisk = input("Enter No.of Disk needed")
d = [ ]
for i in range(int(ndisk)): # Disk size info
    d.append(input("Enter the Size of Disk"))
#d[i] = input("Enter the value of Disk")
vram = input("Enter the memory value")
popup("please note value for specific OS \n A -> Win2012 \n B -> W2K8R2 \n C -> W2K8 X64")
myApp = App("VpxClient.exe")
App.open("C:\\Program Files\\VMware\\Infrastructure\\Virtual Infrastructure Client\\Launcher\\VpxClient.exe")
wait(2)
App.focus("VMware vSphere Client")
popup("Default credential is root \ emclegato")
click("IPaddressnga.png")
type(name)
click("Username.png")
paste("root")
click("Password.png")
paste("emclegato")
click("1343136521911.png")
wait(2)
switchApp("Security Warning")
click("1343136671740.png")
wait(20)
wait(10)
type("n",KEY_CTRL)
wait(15)
switchApp("Create New Virtual Machine")
wait(3)
click("1343140495548.png")
rightClick("EewVirtualMa.png")
wait(1)
type("d")
type(vname)
wait(1)
click("Next-1.png")
click("Next-2.png")
click(Pattern("7MicrosoftWi-1.png").targetOffset(-48,-4))
click("il.png")
click("MicrosoftWin-3.png")
click("1343141758169.png")
doubleClick("40.png")
paste(d[0])
click("Next-3.png")
click("l.png")
click("Continue.png")
if (int(ndisk) > 1):
    ndisk = int(ndisk) - 1
    for i in range(ndisk):
        click("1343153484832.png")
        wait(1.5)
        click("HardDisk.png")
        click("1343145523513.png")
        click(Pattern("7Createanewv.png").targetOffset(-67,-2))
        click("Next-4.png")
        doubleClick(Pattern("IFDiskSize.png").targetOffset(28,0))
        type(d[i+1])
        click("Next-5.png")
        click("Next-6.png")
        click("Finish.png")

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

Revision history for this message
RaiMan (raimund-hocke) said :
#6

The error is a simple "image not found " in your script's line 65

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#7

yeap ... the error is "image not found"..
But the problem is .. my For loop should iterate upto limit.
but For loop is iterating only once ,, and its updating properly in the first iteration. when loop is starting with second iteration, i am getting the following error...

[error] Stopped
[error] An error occurs at line 52
[error] Error message: Traceback (most recent call last):
 File "C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp4695093255318112514.py", line 52, in
 click("1343153484832.png")
 Line 65, in file C:\DOCUME~1\viswas6\LOCALS~1\Temp\sikuli-tmp4695093255318112514.py

so why it happening in second iteration.

Revision history for this message
RaiMan (raimund-hocke) said :
#8

Since I do not have any idea about the visual aspects of your workflow, I cannot tell you, why the image is not found in the second turn.

So you have to do some debugging around the problematic line with some prints and region.highlight(t).

Might be you have to wait a little bit longer for the image:

if exists(image, 5): click(getLastMatch())
else: print "image not found"; exit(1)

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#9

What is getLastMatch() function does??? I am not understanding fro the documentation.

Revision history for this message
RaiMan (raimund-hocke) said :
#10

Each search (explicit like find, exits or implicit like click) store the match with the search region.
So after a search operation you can ask the region, to get the last match e.g. to click on it.

if exists(someImage): click(getLastMatch()) # one search only

instead of

if exists(someImage): click(someImage) # two searches

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#11

please help me to implement that in my task .. since i tried to debug but didn't slove
ndisk =3

if (int(ndisk) > 1):
    ndisk = int(ndisk) - 1
    for i in range(ndisk):
        click("1343153484832.png")
        wait(1.5)
        click("HardDisk.png")
        click("1343145523513.png")
        click(Pattern("7Createanewv.png").targetOffset(-67,-2))
        click("Next-4.png")
        doubleClick(Pattern("IFDiskSize.png").targetOffset(28,0))
        type(d[i+1])
        click("Next-5.png")
        click("Next-6.png")
        click("Finish.png")
else:
    click("Finish-1.png")

iteration is not happening more than once. please help me out if possible.

Much apprriciated your help. Thanks lot :)

Revision history for this message
RaiMan (raimund-hocke) said :
#12

What is the problem?

What happens where?

What and how did you debug?

Revision history for this message
pyCoder (validcode-ye) said :
#13

1) You have to explain what is happening better.
2) You have to do more debugging work, on your own.
       Is the desired image visable for more then 3 seconds before the error is throw?
       Use the builtin image matching tool to see how well the one image is being seen.
       If the computer lags you might have to figure out how to use 'wait(image,timeout)' as it's better practice to wait on an image or pole the image verses blind timed wait(time)'s

Revision history for this message
Launchpad Janitor (janitor) said :
#14

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#15

Close this issue

Revision history for this message
RaiMan (raimund-hocke) said :
#16

user wanted