I'm trying to get headings to print in Selenium and am having no luck placing the headings. The only way they print at all is in the second column but obviously not in the right place. Does anyone know how to position the headings properly? Thanks so much!!
Code
tickers = driver.find_elements(By.CSS_SELECTOR, "a.tv-screener__symbol")
col1 = driver.find_elements(By.XPATH, "//tbody/tr/td[4] | //th")
col2 = driver.find_elements(By.XPATH, "//tbody/tr/td[5]")
col3 = driver.find_elements(By.XPATH, "//tbody/tr/td[6]")
col4 = driver.find_elements(By.XPATH, "//tbody/tr/td[7]")
col5 = driver.find_elements(By.XPATH, "//tbody/tr/td[8]")
col6 = driver.find_elements(By.XPATH, "//tbody/tr/td[9]")
col7 = driver.find_elements(By.XPATH, "//tbody/tr/td[10]")
col8 = driver.find_elements(By.XPATH, "//tbody/tr/td[11]")
col9 = driver.find_elements(By.XPATH, "//tbody/tr/td[12]")
wb = load_workbook(filename='C:\\Users\\Jake\\test.xlsm',
read_only=False,keep_vba=True)
ws1 = wb.create_sheet("Sheet1")
for index in range(len(tickers)):
row = [tickers[index].text, col1[index].text, col2[index].text, col3[index].text, col4[index].text, col5[index].text, col6[index].text, col7[index].text, col8[index].text]
ws1.cell(row=index+1, column=1).value = row[0]
ws1.cell(row=index+1, column=2).value = row[1]
ws1.cell(row=index+1, column=3).value = row[2]
ws1.cell(row=index+1, column=4).value = row[3]
ws1.cell(row=index+1, column=5).value = row[4]
ws1.cell(row=index+1, column=6).value = row[5]
ws1.cell(row=index+1, column=7).value = row[6]
ws1.cell(row=index+1, column=8).value = row[7]
ws1.cell(row=index+1, column=9).value = row[8]
wb.save('c:/Users/Jake/test.xlsm')
Results
source https://stackoverflow.com/questions/70776541/need-help-position-headings-in-the-correct-place-in-selenium
Comments
Post a Comment