Selenium Python- How Can I Fill All Input Fields At Once
Is it possible to fill all the fields on the page at once instead of one by one? Right now I have driver.find_element_by_id('1').send_keys(input1) driver.find_element_by_id('2').se
Solution 1:
You may construct a dict
in python to store the values corresponding to id and Iterate over it to fill up the corresponding data.
input_mapping = {"1": "input1", "2": "input2", "3": "input3"}
for key, value in input_mapping.items():
driver.find_element_by_id(key).send_keys(value)
But the above approach won't be sequential. as the dictionary maintains no order on it's own. So it would be a better choice to use collections.OrderedDict()
if the order really matters
Post a Comment for "Selenium Python- How Can I Fill All Input Fields At Once"