1

I'm trying to select a checkbox on the following public web-page using Selenium XPath from Python and click it to change the checked status.

http://simbad.u-strasbg.fr/simbad/sim-fout

For example, the checkbox that I would like to click is located under "Fluxes/Magnitudes" and is named "U" shown in the picture below.

Upon inspection of this page I built the following XPath to select the checkbox:

//*[@type ='checkbox' and @name='U'] 

This returns what I believe to be the correct element, however when I try to run click() on the object it fails with the exception 'list' object has no attribute 'click'

When I look at the functions for this object in a debugger it indeed does not have a click function.

How can this be true for a checkbox?

Is there a different element that has to be selected?

Thanks!

enter image description here

2 Answers 2

1

importe the required Selenium modules at the beginning of automation Python script:

from selenium import webdriver
from selenium.webdriver.common.by import By

Initialize the WebDriver and navigate to the webpage:

Initialize the WebDriver

driver = webdriver.Chrome()
driver.get("http://simbad.u-strasbg.fr/simbad/sim-fout")

Wait for the checkbox element to be visible

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Wait for the checkbox element to be visible (adjust timeout as needed)
wait = WebDriverWait(driver, 10)
checkbox = wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@type='checkbox' and @name='U']")))

click the checkbox element

checkbox.click()
0

My bad, I was using find_elements_by_xpath instead of find_element_by_xpath

Copy paste error from using another line of code

1
  • 2
    Hi, Brian. You could improve your question by including the code you were using since only you could have answered with the information you posted.
    – Kate Paulk
    Aug 19, 2021 at 11:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.