I am new to python program, don't know much about the syntax of python. I have written a program which will extract the csv data as below.
<html>
<body>
import csv, sys
filename = "inputfile.csv"
reader = csv.reader(open(filename, "rb"))

#rownum = 0

try:
for row in reader:
#if rownum == 0:
# header = row
#else:
colnum = 0
for col in row:
#print '%-8s: %s' % (header[colnum], col)
if colnum == 2:
if col == 'ISLNK':
print 'Found the Link - %s' % row[colnum+1]
elif col == 'ISTXT':
print 'Found the Text - %s' % row[colnum+1]
elif col == 'CRTLK':
print 'Found the control Link - %s, %s' % (row[colnum+1],row[colnum+2])
elif col == 'IMGCM':
print 'Found the Image comaprison - %s' % row[colnum+1]
elif col == 'IMGLK':
print 'Found the Image Link - %s' % row[colnum+1]
else:
print 'Wrong Data is Provided !'
colnum += 1
#rownum += 1

except csv.Error, e:
sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e))
</body> </html>

Below is another class which uses selenium unittest frame work, i want to pass the values that we got from the csv to the selenium commands. I don't want to hard code the text, link and image source in selenium commands. I don't know how to pass the values from on function to another function. Below is selenium program.
<html>
<body>
from selenium import selenium
import unittest, time, re
class NewTest(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "http://wap.aol.com/")
self.selenium.start()

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link=Moviefone")
sel.wait_for_page_to_load("30000")

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link=CityGuide")
sel.wait_for_page_to_load("30000")

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link=News")
sel.wait_for_page_to_load("30000")

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link=Finance")
sel.wait_for_page_to_load("30000")

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link= Asylum")
sel.wait_for_page_to_load("30000")

def test_new(self):
sel = self.selenium
sel.open("/portal/")
sel.click("link=Music")
sel.wait_for_page_to_load("30000")

def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
unittest.main()
</body></html>

Please, edit your above post and put whatever is Python code inside tags like this:

[code=python] CODE GOES HERE [/code]

Indenting is essential to Python, so your code needs to retain it in the post.

This article has been dead for over six months. Start a new discussion instead.