I am looking for a way to shorten my code.
I am gathering captcha values from https://www.ultimateqa.com/complicated-page/ and submitting them for 3 captcha boxes.
Can I shorten my code using a function? Or should I use different css selectors?
for i in range(1):
cap0 = '#et_pb_contact_form_0 > div.et_pb_contact > form > div > div > p > input'
captext1= driver.find_element_by_css_selector(cap0).get_attribute("data-first_digit")
capnumb1 = int(captext1)
captext2= driver.find_element_by_css_selector(cap0).get_attribute("data-second_digit")
capnumb2 = int(captext2)
driver.find_element_by_css_selector(cap0).send_keys(capnumb1 + capnumb2)
for i in range(1):
cap1 = '#et_pb_contact_form_1 > div.et_pb_contact > form > div > div > p > input'
captext1= driver.find_element_by_css_selector(cap1).get_attribute("data-first_digit")
capnumb1 = int(captext1)
captext2= driver.find_element_by_css_selector(cap1).get_attribute("data-second_digit")
capnumb2 = int(captext2)
driver.find_element_by_css_selector(cap1).send_keys(capnumb1 + capnumb2)
for i in range(1):
cap2 = '#et_pb_contact_form_2 > div.et_pb_contact > form > div > div > p > input'
captext1= driver.find_element_by_css_selector(cap2).get_attribute("data-first_digit")
capnumb1 = int(captext1)
captext2= driver.find_element_by_css_selector(cap2).get_attribute("data-second_digit")
capnumb2 = int(captext2)
driver.find_element_by_css_selector(cap2).send_keys(capnumb1 + capnumb2)