I'm having an issue where an error appears in my PYTHON GUI stating 'ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with', so it's stopping my script.
Virtually I have an image below where I select the seats of the passengers in their outbound flight by selecting a seat, the next radio button is selected and then another seat is selected and it continues.
However, after selecting the seat for the last passenger on the outbound flight, it will automatically go down the inbound list and select the first passenger's radio button in there, but the script stops with the error.
I tried stating using xpath to wait for the plane map for the inbound map to appear before clicking on the inbound passengers but it doesn't like that.
My question is that how can I get the script to select the seats for the inbound flight, exactly like the outbound flight once it does the switch from outbound to inbound?
Below is the code I have for selecting passengers and their seats:
#seats selection - outbound
for outbound_passenger in driver.find_elements_by_css_selector("ol[data-flightbound='Outbound'] li[data-personid]"):
outbound_passenger.click()
#driver.find_elements_by_css_selector("ol.passengerlist li[data-personid]"):
outbound_has_infant = outbound_passenger.get_attribute("data-hasinfant")
# choose seats
if outbound_has_infant:
# select a non-selected infant seat
outbound_seat = driver.find_element_by_css_selector(".planebody a.seat.infant:not(.reserved):not(.selected)")
else:
# select a non-reserved non-selected seat
outbound_seat = driver.find_element_by_css_selector(".planebody a.seat:not(.reserved):not(.selected)")
print("Passenger: %s, choosing seat: %s" % (outbound_passenger.text.strip(), outbound_seat.get_attribute("data-seat")))
outbound_seat.click()
inbound_plan = wait.until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[3]/form/div[1]/div/div[1]/div[15]/div[2]/div/div[2]/div[2]")))
#seats selection - inbound
for inbound_passenger in driver.find_elements_by_css_selector("ol[data-flightbound='Inbound'] li[data-personid]"):
inbound_passenger.click()
#driver.find_elements_by_css_selector("ol.passengerlist li[data-personid]"):
inbound_has_infant = inbound_passenger.get_attribute("data-hasinfant")
# choose seats
if inbound_has_infant:
# select a non-selected infant seat
inbound_seat = driver.find_element_by_css_selector(".planebody a.seat.infant:not(.reserved):not(.selected)")
else:
# select a non-reserved non-selected seat
inbound_seat = driver.find_element_by_css_selector(".planebody a.seat:not(.reserved):not(.selected)")
print("Passenger: %s, choosing seat: %s" % (inbound_passenger.text.strip(), inbound_seat.get_attribute("data-seat")))
inbound_seat.click()