79618645

Date: 2025-05-12 21:18:57
Score: 1.5
Natty:
Report link

I think I might see what’s going on here. You're getting a StaleElementReferenceException, right? That usually happens when the element you’re trying to interact with is no longer attached to the page — maybe because the page has refreshed or the DOM has changed after switching the radio button.

After selecting the "Rooms Wanted" option and submitting the search, are you sure the search_box element is still the same? Could it be that the page reloads or rerenders that part of the DOM when the radio button is changed?

You should try to re-find the search_box element after switching to the second radio button like this:

rent_button = driver.find_element(By.ID, "flatshare_type-offered")

driver.execute_script("arguments[0].checked = true;", rent_button)

search_box = driver.find_element(By.ID, "search_by_location_field")

search_box.send_keys(postcode, Keys.ENTER)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: nkhalmatay