The issue i have is that the print statement at the end returns NONE . i want to store the values at every 6 spot in each row which is fine and working correctly .
BUT the print(self.mystr) at the end doesn't give me a value .
please help/ advise.
i log in to this website and use it . trying to automate a few things.
def click_single_tractor(self): #dynamically clicks tractor
sleep(2)
basecss = '#ctl00_ContentPlaceHolder1_PopupControlTractores_TractorGrid_DXMainTable > tbody > tr'
cssbase = '#ctl00_ContentPlaceHolder1_PopupControlTractores_TractorGrid_DXHeadersRow > td'
table_rows = self.driver_web_browser.find_elements_by_css_selector(basecss)
table_data = self.driver_web_browser.find_elements_by_css_selector(cssbase)
for index, tr in enumerate(table_rows,1):
iteratingSelObj = self.driver_web_browser.find_elements_by_css_selector("{}:nth-child({})".format( basecss, str(index)))
print('table row:',int(index))
for indx, td in enumerate(table_data,1):
iterate_td = self.driver_web_browser.find_element_by_css_selector("{}:nth-child({})".format( cssbase, str(indx)))
print('table data:',int(indx))
if indx == 6:
#get value of element
# add to string ? to get value
self.mystr.append(td.get_attribute('text'))
print(self.mystr)
im displaying the rows and table data on purpose as a self check and it returns the right amount of data
7 rows, 10 table datas per row.
the web table is kind of dynamic because occasionally gets an item added to it which is why im reading the info dynamically that way i dont have to mess with the code if we add an item.
result:
table row: 1
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 2
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 3
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 4
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 5
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 6
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
table row: 7
table data: 1 table data: 2 table data: 3 table data: 4 table data: 5 table data: 6 table data: 7 table data: 8 table data: 9 table data: 10
[None, None, None, None, None, None, None]