Tablular Data inside Sikuli?

Asked by Marianne Murray

Hello!

Is it possible to have data inside the script in table format? Instead of list?

(Test users don't have admin rights on the test machines so can't use Python)

My test needs the URL and the title of the page as inputs, so my inelegant solution is to use 2 lists... It works, but i'd feel more confident if the title was always with the URL...

Example for how i got it to work...

UL=(
r"http://url1",
r"http://url2",
r"http://url3")

TL=(
"title1",
"title2",
"title3")

current=0
for i in range (3):
    print (UL[current])
    print (TL[current])
    current+=1

Is there a better way to do it?
I'm concerned that if something happens to the data the lists will get out of sync...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

UTL=(
(r"http://url1", "title1"),
(r"http://url2", "title1"),
(r"http://url3", "title1") )

for i in range (len(UTL)):
    print "URL:", UTL[i][0], "Title:", UTL[i][1])

You might put the stuff in a file like
http://url1; title1
http://url2; title2
http://url3; title3

and read it into your list:

UTL = []
inp = file("some_file.txt")
for line in inp.readlines():
    UTL.append(line.strip().split(";"))

for i in range (len(UTL)):
    print "URL:", UTL[i][0], "Title:", UTL[i][1])

pls. do not blame me for syntax errors - not tested ;-)

Revision history for this message
Marianne Murray (qualitycurls) said :
#2

Beautiful!

I used the first and the only thing missing syntax wise was a (

RaiMan you are a rockstar!

Revision history for this message
Marianne Murray (qualitycurls) said :
#3

Thanks RaiMan, that solved my question.