I've created a script to parse the names and addresses of different results (56 in this case) from a website. The addresses become visible when a click is initiated on each result. However, When I run the following script, I get two results but then I encounter this element not interactable error pointing at this line item.click().
To populate the result it is necessary to fill in the searchbox with this M203DB and hit the search button.
I've tried with:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
def get_content(link):
driver.get(link)
WebDriverWait(driver,20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input.inv_addressSuggestion"))).send_keys('M203DB',Keys.RETURN)
for item in WebDriverWait(driver,20).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "[id^='listItemContainer_']"))):
item.click()
name = item.find_element_by_css_selector("span.detailContactVal").text
address = item.find_element_by_css_selector("span.detailAddr").text
print(name,address)
if __name__ == '__main__':
URL = 'https://www.sjp.co.uk/site-services/find-your-adviser?async=1'
with webdriver.Chrome() as driver:
get_content(URL)
Error the script throws:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
How can I scrape names and addresses out of all the results?