I am working on a project where I need to import an excel sheet into a website form. I'm having trouble with properly reading the data from the sheet and send it using the send_keys.
- First, I created entries in the form:
load_rows = 0
while load_rows < 101:
add_element = driver.find_element_by_css_selector('.form-footer')
add_element.click()
load_rows = load_rows + 1
driver.execute_script("window.scrollTo(0, 1000);")
- Then, I get the data from an excel sheet that matches the required entries on the website:
# Loading the Excel Info
filepath = "trusted_ips.xlsx"
wb = load_workbook(filepath)
ws = wb.active
max_row = sheet.max_row
max_column = sheet.max_column
print("Total columns : ", max_column)
print("Total rows : ", max_row)
It seems like it's storing all of column A into name_elements.. So, the send_keys function is sending all of column A before moving to the next field.
I want it to only send each element to a field, and I think that a list would fix this. But I'm not too sure.
for name_elements in driver.find_elements_by_xpath ('//*[contains(@id,
"_name")]'):
for row in ws['A2':'A100']:
for cell in row:
name_elements.send_keys(cell.value)
print(name_elements)

