I try to gather the json files of the french lobby register for a research project, I can't click the field with my selenium webdriver. that's the location of the button I tried to click both the text or the button itself, but I got an error back, weirdly after a few days I don#t get an error, but the field's still not clickable. The code I used & my prior tries are here:
I'm a student assistant researcher with little to none experience in webscraping, so everything I know is a collection of stack overflow, reddit & google searches.
If you have any ideas, please help :) Have a nice day!
Prior tries that failed: By.CLASS_NAME; By.PARTIAL_LINK_TEXT, By.XPATH didn't work, I tried all with the div class, a class & span location.
Refer the code below with in-line explanation:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Firefox()
driver.get("https://www.hatvp.fr/le-repertoire/liste-des-entites-enregistrees/")
driver.maximize_window()
# Below line will create wait object with 10s
wait = WebDriverWait(driver, 10)
# Below line will click on "PG CONSULTANT" element
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'PG CONSULTANT')]"))).click()
# Below line will capture the number of tabs open on the browser
tabs = driver.window_handles
# Below line will switch to the next tab
driver.switch_to.window(tabs[1])
# Below line will click on the "Télécharger le fichier JSON" element
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Télécharger le fichier JSON']"))).click()
time.sleep(10)