'Iterate through a dictionary and through selenium objects to fill the boxes with corresponding values

Basically I have a html div that contains multiple inputs(for name, surname,etc...). I want to iterate through those inputs with the for loop below shown and insert corresponding dictionary values to the inputs. How do I iterate through both the selenium elements(inputs) and dictionary parallelly and get insert the wanted value.

creds = {'Name': '','Phone': '', 'Surname': '','address': '', 'E-mail': '','Zip': '', 'City': ''}
def credential_input() -> None:
    input_boxes = driver.find_elements(by=By.CSS_SELECTOR, value='div[class*=\'col-6 col-12 two-rows\'] input')
    for input_box in input_boxes:
        input_box.send_keys(creds)


Solution 1:[1]

It depends on the content of the input_boxes variable, however assuming that each element in the iterable is an input element:

i = 0
for key,value in creds.items():
    input_boxes[i].send_keys(value)
    i += 1

or

val_list = list(creds.values())
for i, element in enumerate(input_boxes):
    element.send_keys(val_list[i])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alexpdev