0

I am trying to select a radio check box on a page after it loads. I have tried 3 different ways. Two work and one does not, but I don't understand why. The one that does not work is the one I would like to use.

The below code works with no issues.

wait=WebDriverWait(driver, 30)
el = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="stops-1"]')))
el.click() 

The below code works with no issues.

wait=WebDriverWait(driver, 30)
time.sleep(15)
driver.find_element_by_xpath('//*[@id="stops-1"]').click()

The below code gives the following error. "in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: "

wait=WebDriverWait(driver, 30)
el = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="stops-1"]')))
el.click()

The page loads in about 10 - 15 seconds and the radio is present and I assume clickable because the other methods worked but this one does not.

Any help would be appreciated below is the link to the sight I am trying to work with

https://www.expedia.com/Flights-Search?flight-type=on&mode=search&trip=roundtrip&leg1=from%3AAlbuquerque+%28ABQ+-+Albuquerque+Intl.+Sunport%29%2Cto%3ANew+York+%28NYC+-+All+Airports%29%2Cdeparture%3A4%2F24%2F2021TANYT&options=cabinclass%3Aeconomy&leg2=from%3ANew+York+%28NYC+-+All+Airports%29%2Cto%3AAlbuquerque+%28ABQ+-+Albuquerque+Intl.+Sunport%29%2Cdeparture%3A4%2F25%2F2021TANYT&passengers=children%3A0%2Cadults%3A1%2Cseniors%3A0%2Cinfantinlap%3AY&fromDate=4%2F24%2F2021&toDate=4%2F25%2F2021&d1=2021-04-24&d2=2021-04-25

OsoSuerte
  • 1
  • 1
  • 1
    Does this answer your question? [Difference between EC.element\_to\_be\_clickable and EC.presence\_of\_element\_located to click() an element](https://stackoverflow.com/questions/61494149/difference-between-ec-element-to-be-clickable-and-ec-presence-of-element-located) – Ajay Apr 10 '21 at 21:05
  • I am sorry but I don't understand how this explains why I am getting a timeout exception for an item that is clickable. The code is supposed to wait until the element is clickable "returns true" and then advance. So why is it timing out if the element is clickable? – OsoSuerte Apr 10 '21 at 21:27
  • 1
    The other methods don't check to see if the element is clickable (enabled). That's apparently why they work and waiting for clickable doesn't. We can't see why that might be without a link to the page because you haven't provided the relevant HTML. You also haven't provided the code for the `clk()` method in your second attempt so we can't comment on that one at all. – JeffC Apr 10 '21 at 23:11
  • I removed the clk() method (sorry). The site is an Expedia flight search and trying to select the "1 stop" radio. I also added a link to the page. – OsoSuerte Apr 10 '21 at 23:54

0 Answers0