← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #671416]: Script attempts to run then immediately stops, but provides no error msg

 

Question #671416 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/671416

Description changed to:
When I click "Run" or "Run in slow motion", the SikuliX IDE attempts to
run my script, but then it immediately stops.  However it provides no
error output - in fact, it provides no feedback whatsoever in the
"Message" window.

This has been occurring all morning.  I copied my script, then re-
entered it line by line by hand.  When I attempted to run it, it threw
an error on a line where I had a typo.  I corrected the typo, saved it,
but now it's doing the "I'll give you no feedback whatsoever" thing
again.

Could there perhaps be an issue with indentation?  I have gone over the
code many times, and it *looks* OK to me (my wife would roll her eyes,
she knows how well I look at stuff). I know that I must be missing
something.  I wish the IDE would give me some sort of feedback on why it
won't run, but it is not being helpful at all.

I should note that I have also reinstalled SikuliX just to be safe.
Unfortunately that did not help.

The code is below.  Any help/input is quite appreciated!

Thank you in advance,

Ron

#####################
import os
import shutil
import datetime

### Beginning Class PDA ###
class PDA(object):

    def __init__(self):
		self.BasePath = "c:\\screenshots"
		self.Browser = "Chrome"
		self.TestSite = "Test"
		self.TestType = "Default"
		self.SSCount = 0
		self.FolderDate = str(datetime.date.strftime(datetime.datetime.date(datetime.datetime.now()),'%m-%d-%y'))
		self.FullPath = ""
		self.SiteURL = "https://www.google.com/";

    def TakeScreenShot(self, path):
        #increment screenshot count
        self.SSCount += 1

        # cast the count to string
        strcount = str(self.SSCount)

        #format out filename using the SS count
        nextname = self.FormatSSName(strcount)

        # get our main full screen coords defined
        screen = (SCREEN.getX(), SCREEN.getY(), SCREEN.getW(), SCREEN.getH())

        # capture the defined screen      
        img = capture(*screen)

        #put the pieces of our new filename into a list
        strjoin = (path, nextname)

        # concatenate the path with the filename (putting a backslash between them)
        newFile = "\\".join(strjoin)

        # save the screenshot
        shutil.copy(img, newFile)

    def FormatSSName(self, strcount):

        strPad = ""

        # Determine length of our SS Count, then prepend the appropriuate # of zeroes to its number and append a .png
        if len(strcount) == 1:
            strPad = "0000" + strcount
            strPad = strPad + ".png"
        elif len(strcount) == 2:
            strPad = "000" + strcount
            strPad = strPad + ".png"
        elif len(strcount) == 3:
            strPad = "00" + strcount
            strPad = strPad + ".png"
        elif len(strcount) == 4:
            strPad = "0" + strcount
            strPad = strPad + ".png"
        else:
            strPad = strcount + ".png"

        return strPad

    def SetupBrowser(self):

        #extract browser filename from PDA.Browser property
        browsername = os.path.basename(self.Browser)

        #Close all instances of the aforementioned browser
        closeApp(browsername)

        wait(5)

        #Define our browser object
        pdaBrowser = App(self.Browser)

        wait(2)

        #Open the browser
        pdaBrowser.open()

        wait(5)

        #Focus on the browser
        pdaBrowser.focus()

        wait(2)

        #Access the address bar
        type("l", KeyModifier.CTRL)

        wait(2)

        #Enter Site URL and navigate to it
        type(self.SiteURL + Key.ENTER)

### Ending Class PDA ###

### SET ENVIRONMENT ###
# Define PDA object
myPDA = PDA()

# define path, browser type, folder names and navigation URL
myPDA.BasePath = "C:\\screenshots\\sikulitest"
myPDA.Browser  = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
myPDA.TestSite = "TestSite"
myPDA.TestType = "Default"
myPDA.SiteURL  = "https://www.google.com";

backslash = "\\"
pathinfo  = (myPDA.BasePath, myPDA.TestSite, myPDA.FolderDate, myPDA.TestType)

#Concatenate  full path string
myPDA.FullPath = backslash.join(pathinfo)

#Store path in dir obj
myPath = os.path.dirname(myPDA.FullPath)

#Check if path exists.  If not, create it
if not os.path.exists(myPath):
    os.makedirs(myPath)

#Setup our browser
myPDA.SetupBrowser

#Take a screenshot
myPDA.TakeScreenShot(myPath)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.