Tuple item processing for selenium automation – Python

I have a list of multiple tuples and each tuple further has multiple items and i want to process the items of each tuples into application using selenium web driver

list_of_tuple = [('New year offer', 'Avaliabe upto 31 dec', '[email protected]', '02/02/2021'), ('Dipawali offer', '20% off dec', '[email protected]', '05/19/2021'), ('Xmas', '50% of clothes', '[email protected]', '11/11/2021'), ('New year offer', 'Available unto 31 Dec', '[email protected]', '02/02/2021')]

And the scenario is like this: There are four text fields in a web application, and I want to enter (process) the each items (4 items in this case) of an induvial tuple into respective text field and I want to repeat this multiple times

How can I achieve this? please help

Regards, Ram

Answer

driver = webdriver.Chrome() # driver object

field1 = driver.find_element_by_xpath('//*[@id="field1"]') # X-Path of field 1
field2 = driver.find_element_by_xpath('//*[@id="field2"]') # X-Path of field 2
field3 = driver.find_element_by_xpath('//*[@id="field3"]') # X-Path of field 3
field4 = driver.find_element_by_xpath('//*[@id="field4"]') # X-Path of field 4
submit = driver.find_element_by_xpath('//*[@id="submit"]') # X-Path of submit

for i in list_of_tuples :
    field1.send_keys(i[0]) 
    field2.send_keys(i[1])
    field3.send_keys(i[2])
    field4.send_keys(i[3])
    submit.click() # Sending click to the submit button.