Wednesday, September 26, 2012

Multiple field is checking When restarting an application with exception and logging in sikuli


Description:
This script is checking multiple field When user changing an Field after reopen an application. Here, I have choose Pathway Configuration Tool and It code contain Exception handling when field failed then popup message box will invoke an error line. Those error line is inserted in log file in temp directory.

Example code:

# Exception handling
import sys, re, traceback, os
setThrowException(True)
try:
    openPH()
    PHAction()
    openPH_two()
    click("TestI.png"), click("PrDDerties.png"), wait("PaeSize.png")
  
    Page_Size = find("HalfIetter.png").highlight(2)
    Justified = find("JustifiedYes.png").inside().find("Yes-1.png").highlight(2)
    Fixed_Line_Height = find("IUIFixedLine.png").inside().find("1348489050687.png").highlight(2)
    Running_Header = find("EveryPage-1.png").highlight(2)
    Page_Number = find("PaueNumbers.png").inside().find("ButtumLeftMa.png").highlight(2)

except:
    err = str(sys.exc_info()[1])
    errs = err.split()[4]
    pth = sys.argv[0]
    ful_err = traceback.format_exc()
    vrie = ful_err.split()[11]
    PTR = 'This ' + str(vrie) + ' field is failed. So, Please find a picture in ' + str(pth) + str(errs) + ' path.'
    print PTR
    logger.error(PTR) 
    popup(PTR)

 # Creating Log file

def logdirs():
    global dirname
    dirname = "C:\\WINDOWS\\TEMP\\Sikuli_logs\\"
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    else:
#      os.remove(dirname)
        print "Directory is already created..."
import logging, os
logdirs()
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('C:\\WINDOWS\\TEMP\\Sikuli_logs\\Pathway.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.ERROR)

Demo view in video:

Youtube links : https://www.youtube.com/watch?v=e-wwPrDcoR8



Sunday, September 16, 2012

Train availability status automated by sikuli tool



Scenario :
View train availability between two station in live website.


Feature in script:

                      This script is used for password encryption when you enter in input box and tool tip used to highlight some area for user attraction then inside find region used to click particular area.

Example :
Below, code line is give to understand for above feature.

# Password encription
import javax.swing.JOptionPane as JOP
import javax.swing.JPasswordField as JPF
pwdF = JPF()

IN = input("Enter a user name")
type("Username-2.png", IN)
JOP.showConfirmDialog(None, pwdF,
        "Please enter Password",
        JOP.OK_CANCEL_OPTION)
passwd = pwdF.getText()
type("Password-2.png", passwd + Key.ENTER)
click("1347731963166.png"),

# Inside find

Er = find("12631NELLAIE.png").inside().find("1347731427595.png").right(38)
click(Er)

# Tooltip and highlight
from guide import *
text("TrainDetails.png", "Train Details")
show(2)
m = find("TrainName-1.png")
m.highlight(2)
tooltip("NELLAIEXPRES.png","NELLAI EXPRESS")
show(5)


Demo view in Video :


Youtube links :http://www.youtube.com/watch?v=8ZyE_-rGI6s&feature=plcp


Note : I have given above video for easy to understand and this is taken When the script run on sikuli IDE

Monday, April 9, 2012

Sikuli scripts handled When crash on Fieldworks.


Scenario : Sikuli scripts handled When crash on Fieldworks.

Explanation :
I automated, When Crash is appears on flex using sikuli script(E.g Particular scenario). Its mean, If suppose crash appears while testing on flex then screenshot and error lines are saved on appropriate file path.

E.g

import os
ERR = find("Anerrorhasoc-1.png").below(450)
ERR.click("1332009700327-1.png")
click("iewDetalIs-1.png"), sleep(5)
assertNotExist("Anerrorhasoc.png")

#def Test_D(self): # Taking screenshot in MSpaint
wait(1)
type(Key.PRINTSCREEN)
wait(1)
openApp("mspaint.exe")
wait(3)
type("v",KEY_CTRL)
type("s",KEY_CTRL), wait(0.40)
type(Key.BACKSPACE), wait(0.40)
type("Filename-1.png", "Text"), click("1332053249614.png"), wait(0.30)
closeApp("Text - Paint")
click("1333175341121.png")

#def Test_C(self): # Taking error line
dir = r"F:\Office\Script\sikulitestfiles"
fname = "Text.txt"
os.popen("start /D %s %s"%(dir,fname))
wait(5)
type("v",KEY_CTRL)
type("s",KEY_CTRL)
closeApp("Text - Notepad")



Note : Please watch below video to understand easy way.


Thursday, April 5, 2012

Read lines from *.txt file(Notepad) and pasted into an application using sikuli

Scenario : Creating new text on interlinear pane and insert a add approve analysis in word analysis pane.

Explanation :
This scenario is created for mainly to read lines from *.txt file and pasted into an application using python syntax. I have added this script into sikuli script and given below for sample code to understand.

Example :

theFile = file(r"F:\Office\Script\sikulitestfiles\Text.txt")
for line in theFile:
print line # print line in sikuli
click("1330680438453.png"), type(line)
theFile.close()

Full Code in picture view :


Demo view in Video :

Note : I have given below video for easy to understand and this is taken When the script run on sikuli IDE

Blue burry software(bbsoftware) for video Recorder on desktop screen

Hello All,

I am using video recorder software on desktop screen last two week. Its seem useful. We can able to record video with sound and web cam even though Video export is available to flash(*.swf) and Flv format and We can select our full window, region and window on screen while recording video then frame changing option also there. I Think , This video is useful to take video when run a sikuli script.

The tool link is “www.bbsoftware.co.uk/ ”  while downloading  in your system they will ask to enter your email ID to send free license then If you mayn't get free key then you need to send an email to support team(keys@bbsoftware.co.uk) then they will provide a free license in your name with appropriate mail ID.

Tuesday, April 3, 2012

Find out time delay between Lexicon to Categorized Entry pane.


Scenario : Find out time delay between Lexicon to Categorized Entry pane.

Explanation :
The time delay is found by using “time.time()” function in Python and the timer is started When click on first pane then second timer is ended when click on second pane. Total time delay is got subtract between second pane to first pane and the value is displayed in popup message box.
Please refer below picture to view code.

E.g
click("Lexicon.png") # first pane
start = time.time()
click("CdegorizedEn.png") # second pane
find("SemanticDoma.png")
actWait = time.time()-start

Code :

Video :


Sikuli - Software Automation Tool

Sikuli


What is Sikuli ?

Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using images (screenshots). Sikuli includes Sikuli Script, a visual scripting API for Jython, and Sikuli IDE, an integrated development environment for writing visual scripts with screenshots easily. Sikuli Script automates anything you see on the screen without internal API's support. You can pro-grammatically control a web page, a Windows/Linux/Mac OS X desktop application, or even an iphone or android application running in a simulator or via VNC.

Why ? and How it works?

Sikuli: Seeing Pixels

Sikuli's greatest value is its generality, "If it has pixels that Sikuli can see, and then it's open to automation". The technique is open to any application with a GUI that can display on a Windows, Mac, or Linux desktop. Users have already been apply it to not just desktop applications, but also Web pages, video games, mobile phone apps (running in a simulator or using a remote connection between the desktop and the phone), and applications from other platforms running in a virtual machine.

User Interface for Taking Screenshots

Sikuli Search allows a user to select a region of interest on the screen, submit the image in the region as a query to the search engine, and browse the search results. To specify the region of interest, a user presses a hot-key to switch to Sikuli Search mode and begins to drag out a rubber-band rectangle around it. Users do not need to fit the rectangle perfectly around a GUI element since screenshot representation scheme allows inexact match. After the rectangle is drawn, a search button appears next to it, which submits the image in the rectangle as a query to the search engine and opens a web browser to display the results.
Sikuli Script’s annotation interface allows a user to save screenshots with custom annotations that can be looked up using screenshots. To save a screenshot of a GUI element, the user draws a rectangle around it to capture its screenshot to save in the visual index. The user then enters the annotation to be linked to the screenshot. Optionally, the user can mark a specific part of the GUI element (e.g., a button in a dialog box) to which the annotation is directed.

Example : Taking ScreenShot



Please click below links and get more detail about sikuli and python.
http://www.scribd.com/doc/87618834/sikuli-detailed-Doc
http://www.scribd.com/doc/87619779/Bob-Igo-Sikuli-Cposc2010
http://www.scribd.com/doc/87619980/Sikuli-Google
http://www.scribd.com/doc/87756626/Python-Tutorial
http://www.scribd.com/doc/87757365/sikuli-harvardmedicalschool

Below post will give some example sikuli scripts and videos.