← Back to team overview

sikuli-driver team mailing list archive

[Question #210756]: Not able to write the text file.

 

New question #210756 on Sikuli:
https://answers.launchpad.net/sikuli/+question/210756

Dear friend,

I have doing read and write text file using sikuli.
See the following example.

setThrowException(True)
import array
arr=[]
f=open("D:\DPRead.txt","r")
fout = open("D:\DPRead-results.txt","w")

for line in f.readlines():
    arr.append(line.strip()) # get rid of newline
f.close()
wait(2)
click("1348813496420-3.png")
wait(5)
click("earthprogram-3.png")
type("firefox" + Key.ENTER)
wait(5)
type("t", KeyModifier.CTRL)
wait(5)
type("http://abcd/index.action"; + Key.ENTER)
wait("LoginUsernam-3.png",20)
click("Username-3.png")
type("adminani")
click("Password-3.png")
type("Password1")
click("1349777086675-3.png")
wait(2)
wait("1349777342392-3.png",200)
click("Reports-3.png")
wait(1)
click("EmployeeAtte-7.png")
wait("EmployeeAtte-6.png",90)
click("000000-5.png")
wait(2)
type(Key.RIGHT + Key.RIGHT + Key.RIGHT + Key.RIGHT +Key.RIGHT )
type(Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE+ Key.BACKSPACE)
wait(2)
type(arr[0])
wait(2)
click("235959-4.png")
wait(2)
type(Key.RIGHT + Key.RIGHT + Key.RIGHT + Key.RIGHT +Key.RIGHT )
type(Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE + Key.BACKSPACE+ Key.BACKSPACE)
wait(2)
type(arr[1])
wait(2)
click("FEmployeeCod-6.png")
wait(2)
type(Key.TAB)
wait(2)
type(arr[2])
wait(2)
type(Key.TAB)
wait(2)
click("ShowAttendan-3.png" )
wait(10)
type(Key.PAGE_DOWN + Key.PAGE_DOWN)
wait(2)
if exists ("ULUNPAID-5.png"):
    type("UL")
    my_dir = "D:\\"
    el = "\n" # the end of line you want to use
    my_file=file(my_dir + "DPWrite.txt", "w")
    my_file.write("UL"+el) # if you want to have line breaks
    wait(2)
if exists ("WOWEEKLYOFF-5.png"):
    type("WO")
    my_file.write("WO"+el) # if you want to have line breaks
    wait(2)
if exists ("CLCASUAL-5.png"):
    type("CL")
    my_file.write("CL"+el) # if you want to have line breaks
    wait(2)
if exists ("PFPresentFul-4.png"):
    type("PF")
    my_file.write("PF"+el) # if you want to have line breaks
    my_file.close()
    wait(2)    
wait(2)


In this I am able to read the file ..i.e. DPRead.txt
But I am not able to write the DPWrite.txt

I have only execute following sikuli script:

wait(2)
if exists ("ULUNPAID-5.png"):
    type("UL")
    my_dir = "D:\\"
    el = "\n" # the end of line you want to use
    my_file=file(my_dir + "DPWrite.txt", "w")
    my_file.write("UL"+el) # if you want to have line breaks
    wait(2)
if exists ("WOWEEKLYOFF-5.png"):
    type("WO")
    my_file.write("WO"+el) # if you want to have line breaks
    wait(2)
if exists ("CLCASUAL-5.png"):
    type("CL")
    my_file.write("CL"+el) # if you want to have line breaks
    wait(2)
if exists ("PFPresentFul-4.png"):
    type("PF")
    my_file.write("PF"+el) # if you want to have line breaks
    my_file.close()
    wait(2)    
wait(2)

then I am able to write the text file "DPWrite.txt"

Que1: Why I am not able to write the text file.
Que2: Is there any way to read and write same file.
- I have tried it. But does not work.



-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.