Hey all, I just wanna click this button with python my code:
Main_page=webdriver.Chrome(options=chrome_options,service=chrome_service)
base_url="https://www.cbs.gov.il/he/Statistics/Pages/מחוללים/מחולל-תאונות.aspx"
Main_page.get(base_url)
Main_page.maximize_window()
time.sleep(10)
button = Main_page.find_element(By.NAME, 'ישראל כולל יהודה ושומרון')
button.click()
i can figure it out why is not working
error: oSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="ישראל כולל יהודה ושומרון"]"} (Session info: chrome=102.0.5005.63)
CodePudding user response:
check this article https://www.geeksforgeeks.org/click-element-method-selenium-python/
NOTE : you can also use xpath to find elements
element = driver.find_element_by_xpath("//a[@id='link']")
NOTE : you can copy xpath from any Browser here is how to find xpath in browsers
CodePudding user response:
button = Main_page.find_element(By.NAME, 'ישראל כולל יהודה ושומרון')
button.click()
you try to find elements by name , but שראל כולל יהודה ושומרון
its not a valid html or xml name its an innerText of the button ,
try to find using xpath as i mentioned bef or find it by id