Selenium unable to locate element. Trying to navigate through a website that forces you to select certain elements as you go in order to define the final request. I am not sure, but from what I have found already on here the fact that the button is of Radio type may be important.
Here is the part of my code that works so far in order to launch driver, click past cookies, resize and scroll the page so that the element is visible. I do not believe that the resize and scroll is necessary from what I understand of finding elements by Xpath, but I did it anyway to eliminate possible causes for issue.
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Key
from webdriver_manager.chrome import ChromeDriverManager
url = "https://www.valencia.es/es/cas/atencion-ciudadana/comunicar-una-incidencia"
driver = webdriver.Chrome(executable_path=r"/usr/local/bin/chromedriver")
time.sleep(1)
driver.get(url)
time.sleep(1)
Cookies = driver.find_element_by_xpath("/html/body/div[2]/div/div[2]/button[1]")
Cookies.click()
driver.maximize_window()
driver.execute_script("scroll(0, 1000)")
This is the element that I am trying to find:
<input type="radio" name="Grupo" value="GCOM-001" onclick="javascript: submit();">
And here is the code for my attempt to click with Xpath:
driver.find_element_by_xpath(".//input[@type='radio' and @value='GCOM-001']").click()
And my attempt using CSS_Selector:
driver.find_element_by_css_selector("input[type='radio'][value='GCOM-001']").click()
I am unable to find the element using either of these two methods (nor numerous other previous iterations). In both cases this is the returned error.
NoSuchElementException: Message: no such element: Unable to locate element:
Any help would be greatly appreciated.
Note: in case it matters, I am working on a Mac with OS13.1 and an M1 chip.