I have on a web page a [Add Field] button, and when pressed, it will then display a single select list (drop-down menu).
The xpath of this single select drop-down list is: '//*[@id="adv_options[3][]'
With the second array item being empty l like '[]'
.
I have code that will select the correct item on the first 'Add Field', but if I click 'Add Field' again, it displays another single select drop-down menu (with the same options), and the xpath of the second one is the same: '//*[@id="adv_options[3][]'
and so now if I try to select from that menu using that xpath, it will select the first one, and not the second one.
The site may be poorly coded, how would I select the correct item from the 2nd, 3rd, or forth single select drop-down menu option?
Update:
The following works to select the first item from the first drop down:
element = self.driver.find_element(By.XPATH, '//*starts-with(@id, 'adv_options[3][]')
select=Select(element)
select.select_by_value('1506')
Now there is a second drop down with the same id (adv_options[3][]), that I cannot find by xpath and select items from.
If anyone has encountered this and found code that would work, please share.