<input id="value(Medications1)_139038" class="medMedications text-field" type="text" style="width:90%" value="Lantus" maxlength="30000" name="value(Medications1)" autocomplete="off"/>
So there is this page where there are textboxes and these textboxes are not fixed in number. other times it could be 20 and sometimes just 5 it's random. So is there a way to know how many of these textboxes are in the page? and get the values of those textboxes?
I've tried this:
medicationstextbox_locator = "//*[@class='medMedications text-field ']"
medicationstextbox_locatorTextBox = driver.find_elements_by_xpath(medicationstextbox_locator)
for i in medicationstextbox_locatorTextBox:
print(i.get_attribute("values"))
this prints out a lot of None.
I don't get it caused I've accessed it's class, pulled the value but it returns None.
If it's possible I'd want to avoid doing:
medications1 = "//input[@name='value(Medications1)']"
medications2 = "//input[@name='value(Medications2)']"
med1textbox = driver.find_element_by_xpath(med1)
med2textbox = driver.find_element_by_xpath(med2)
med1textbox.get_attribute("value")
med2textbox.get_attribute("value")
because I'd have to define each textbox and the number of textboxes is not known beforehand. It would also take so much time to do it this way. So, how do we solve this?