0

I am currently working on this webpage:

https://www.orbitz.com/Flights-Search?trip=oneway&leg1=from:Hong%20Kong,to:New%20York%20City,departure:01/01/2018TANYT&passengers=children:0,adults:1,seniors:0,infantinlap:Y&mode=search

My code:

#function for searching for all "details" button, return list
def search_detail_button():
    detail_buttons = browser.find_elements_by_css_selector("span.show-flight-details")
    return (detail_buttons)

##Open all details pages
def open_details():
    time.sleep(3)
    for button in search_detail_button():
        button.click()
        time.sleep(1.5)

open_details()

Expected result:

All "Flight details and baggage fees" would be opened.

Actual result:

Sometimes it works, sometimes it gives me an exception. Why would a code sometimes work, sometimes don't?

Nick123
  • 197
  • 1
  • 10
  • 1
    Which `exception` do you observe and at which line? Update the question with error stack trace. – undetected Selenium Dec 07 '17 at 13:13
  • Somehow I'm not getting any exception now after I lengthened the sleep time from 3 to 5. I believe the exception is "element not visible". – Nick123 Dec 07 '17 at 13:39
  • Possible duplicate of [ElementNotVisibleException : Selenium Python](https://stackoverflow.com/questions/47108512/elementnotvisibleexception-selenium-python) – undetected Selenium Dec 07 '17 at 13:41
  • I just got the exception: Element is not clickable. Could it be the case that the elements moved in position? – Nick123 Dec 07 '17 at 13:42
  • For `Element is not clickable` see this QA - https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el/44916498#44916498 – undetected Selenium Dec 07 '17 at 13:43
  • Unfortunately I'm not familiar with Java. I am using Python. The link you above seems to be for Java. – Nick123 Dec 07 '17 at 13:48

0 Answers0