Dict reader attribute error

456 views
Skip to first unread message

chandu

unread,
Jun 25, 2010, 5:50:57 AM6/25/10
to Marathon Java GUI Testing
*****************************************************
##########################################


#######################################
#{{{ Marathon Fixture
from default import *
import csv
#}}} Marathon Fixture

def test():
java_recorded_version = '1.6.0_11'
reader=csv.DictReader(file("D/one.csv"))

if window(''):
select_menu('Documentation>>Booking')

if frame('Booking UAS'):
click('New')
close()

if window('Booking UAS'):
click('Yes')
close()

if frame('Booking UAS'):
select('POL', record["POL"])
select('POD', record["POD"])
select('Customer Name', 'SOLVER SUN')
close()

if window('Customer'):
doubleclick('DsGrid', '{0, System Code}')
close()

if frame('Booking UAS'):
select('ComboBox1', 'Normal')
click('Routing')
close()

if window('Routing'):
doubleclick('DsGrid', '{48, Mode}')
close()

if frame('Booking UAS'):
click('TextField15')
close()

if window('(1)'):
doubleclick('DsGrid', '{4, Voyage}')
close()

if frame('Booking UAS'):
select('Same as Previous service', 'true')
click('search29')
close()

if window('Search Carriage Term'):
doubleclick('Table', '{3, Carriage Term}')
close()

if frame('Booking UAS'):
select('ComboBox1', 'Rates')
click('Save')
close()

if window('Booking UAS'):
click('OK')
close()

if frame('Booking UAS'):
click('Save')
close()

if window('Booking UAS'):
click('OK')
close()

if frame('Booking UAS'):
select('ComboBox1', 'Normal')
click('search33')
close()

if window('Search Equipments'):
doubleclick('Table', '{3, Equipment Code }')
close()

if frame('Booking UAS'):
select('SIntText', '1')
click('add')
close()

if window('Booking UAS'):
click('OK')
close()

if frame('Booking UAS'):
click('Save')
close()

if window('Booking UAS'):
click('OK')
close()
close()

*********************************************************



ISSUE

********************************************************
<type 'exceptions.AttributeError'>: 'module' object has no attribute
'DictReader' C:\Documents and Settings\suneel\Booking\Untitled1 line 8
in function test



Sampath we tried with Dictreader but it is showing attribute error

Sampathkumar R

unread,
Jun 25, 2010, 8:48:34 AM6/25/10
to marathon...@googlegroups.com
Hi,

The most likely cause for the error appearing is "creating" a module
by the name csv. If you have created a module by the name "csv", try
deleting it and create the module with other name.
Jython library has a module by the name csv in it, which has to be
used to read from CSV files.

With regards,
Sampathkumar R.

> --
> You received this message because you are subscribed to the Google
> Groups "Marathon Java GUI Testing" group.
> To post to this group, send email to marathon-
> tes...@googlegroups.com.
> To unsubscribe from this group, send email to marathon-testi...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/marathon-testing?hl=en
> .
>

chandu

unread,
Jun 26, 2010, 5:42:28 AM6/26/10
to Marathon Java GUI Testing
Just my moto is to read the data using csv

On Jun 25, 5:48 pm, Sampathkumar R <sampathkuma...@jaliansystems.com>
wrote:

Sampathkumar R

unread,
Jun 28, 2010, 1:17:17 AM6/28/10
to marathon...@googlegroups.com

Hi,

Here I am attaching the sample application to read the test data from
a csv file and test it. Kindly unzip and open this application from
Marathon.
Update the "Python home" under "Python Path" tab in the menu Marathon -
> Project Settings to point to your Jython home (Note that version of
Jython should be 2.5).
Play the script "CSVReadTest.py" and let me know the outcome.

With regards,
Sampathkumar R

SampleCSVRead.zip

chandu

unread,
Jun 28, 2010, 5:01:18 AM6/28/10
to Marathon Java GUI Testing
I was able to work with sample script but when i try for other it is
showing error

Here iam attaching full script


############################################

#{{{ Marathon Fixture
from default import *
#}}} Marathon Fixture
import csv

def test():
java_recorded_version = '1.5.0_24'

reader=csv.DictReader(file("D:\a.csv"))
if window('Agency Resource Planning - ARP'):
select_menu('Test>>Module Index')

if window('Input'):
click('OK')
close()

if frame('Outstanding Freight Report'):
click('New')
close()

if window('Outstanding Freight Report'):
click('Yes')
close()

if frame('Outstanding Freight Report'):
for record in reader:
select('Report for 1', record["Report"])
select('Currency 1', record["currency"])
click('Show')
click('export')
close()

if window('Export Options'):
click('Generate')
close()

if window('Save As'):
select('FileChooser', '#H/My Documents/aa')
close()

if window('Outstanding Freight Report'):
click('OK')
close()
close()

######################################################################

Iam getting script exception:IndentationError:unindent does not match
any outer indentation level




On Jun 28, 10:17 am, Sampathkumar R <sampathkuma...@jaliansystems.com>
wrote:
>  SampleCSVRead.zip
> 143KViewDownload

chandu

unread,
Jun 28, 2010, 5:41:39 AM6/28/10
to Marathon Java GUI Testing
Here while reading the values in the csv, for example if we have 5
records while passing those records as input system is taking the last
record which is present in the csv and then executing the total block
with that record only.

Can you tell me the functionality how to read the total records
instead of taking last record present in csv

It was able to read the first record value as input from there itself
it is erasing the first one and going to second.Like wise upto last
but one.

Sampathkumar R

unread,
Jun 28, 2010, 5:47:34 AM6/28/10
to marathon...@googlegroups.com
Hi,

IndentationError is caused by improper indentation of the Jython script.
Jython is sensitive to indentation too. I request you to have a look
at Jython's tutorial available at Marathon blog under the
"Documentation" as Jython Tutorial: Part - 1 and Part - 2.

With regards,
Sampathkumar R

chandu

unread,
Jun 29, 2010, 5:58:53 AM6/29/10
to Marathon Java GUI Testing
Hi


Here while reading the values in the csv, for example if we
have 5
records while passing those records as input system is taking the last
record which is present in the csv and then executing the total block
with that record only.

Can you tell me the functionality how to read the total records
instead of taking last record present in csv

It was able to read the first record value as input from there itself
it is erasing the first one and going to second.Like wise upto last
but one.





On Jun 28, 2:47 pm, Sampathkumar R <sampathkuma...@jaliansystems.com>
Reply all
Reply to author
Forward
0 new messages