I'm trying to load this page in full: https://candidat.pole-emploi.fr/offres/emploi/horticulteur/s1m1
I've set a line of code to handle the cookies popup.
Then I've set some lines to click on the Load More Results button in order to have the full html loaded and then printing it.
But I hit an error message after it clicked once :
StaleElementReferenceException: stale element reference: element is not attached to the page document
I don't know what it means nor how to fix it
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import time
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
site = 'https://candidat.pole-emploi.fr/offres/emploi/horticulteur/s1m1'
wd = webdriver.Chrome("C:\Program Files (x86)\chromedriver.exe", options=options)
wd.get(site)
time.sleep(10)
wait = WebDriverWait(wd, 10)
# click cookies popup
wd.find_element_by_xpath('//*[(@id = "description")]//*[contains(concat( " ", @class, " " ), concat( " ", "tc-open-privacy-center", " " ))]').click()
time.sleep(10)
# click show more button until no more results to load
while True:
try:
more_button = wait.until(EC.visibility_of_element_located((By.LINK_TEXT, 'AFFICHER LES 20 OFFRES SUIVANTES'))).click()
except TimeoutException:
break
time.sleep(10)
print(wd.page_source)
print("Complete")
time.sleep(10)
wd.quit()