1

url of the website

enter image description here

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/%D7%9E%D7%97%D7%95%D7%9C%D7%9C%D7%99%D7%9D/%D7%9E%D7%97%D7%95%D7%9C%D7%9C-%D7%AA%D7%90%D7%95%D7%A0%D7%95%D7%AA.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)

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
Hey , i have used the tool but still, i have an error code: Main_page=webdriver.Chrome(options=chrome_options,service=chrome_service) base_url="https://www.cbs.gov.il/he/Statistics/Pages/%D7%9E%D7%97%D7%95%D7%9C%D7%9C%D7%99%D7%9D/%D7%9E%D7%97%D7%95%D7%9C%D7%9C-%D7%AA%D7%90%D7%95%D7%A0%D7%95%D7%AA.aspx" Main_page.get(base_url) Main_page.maximize_window() time.sleep(15) button = Main_page.find_element(By.XPATH, "/html/body/form/div[3]/div/div/div[2]/div[1]/div[1]/ul/li[1]/div/div/div/div/ul/li[3]") button.click()
2
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.