I’ve a situation, which I’m discovering bit troublesome to automate.
The take a look at situation is :
There are two drop down.
- To pick the state.
- To pick the respective cities.
So, I would like to write down a script to automate, the place I would like to pick out a state from State drop down and for that state I would like to pick out all of the cities one after the opposite. As soon as all of the cities are chosen for that respective state, I would like to come back out of that loop and choose a distinct state and repeat this course of.
That is the code which i’ve written.
def test_state(self):
aspect = self.getAllTheElements(self.Register_page_elements,'xpath', 'possibility')
for hyperlink in aspect:
if hyperlink.get_attribute('worth'):
hyperlink.click on()
print("take a look at")
time.sleep(4)
aspect = self.getAllTheElements('autocomplete-city', 'id', 'possibility')
for link2 in aspect:
if link2.get_attribute("worth"):
link2.click on()
print("state")
time.sleep(2)
Since I’ve not given break assertion, it can throw an error after finishing whole iteration.
However, if I give a break it wont work the way in which I need.
That is the HTML code of the drop down.
For state.
As soon as I choose the state then town drop down will seem.