The address below is the xpath address.
//label[@for="check54490"])
The check box is checked when typed as below.
driver.find_element_by_xpath('//label[@for="check54490"]').click()
However, there are many check boxes that need to be checked, so I am going to make variables and check them.
I made a variable as below, but an error occurs.
umber = [54490]
for num in umber:
elem = f'//label[@for="check{num}"]'
elm2 = f"'{elem}'"
xpath = elem2
driver.find_element_by_xpath(xpath).click()
the error message is as follows.
Is the approach good or is it impossible in the first place?
Please give me some advice.
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression driver.find_element_by_xpath('//label[@for="check1000054759"]').click() because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string 'driver.find_element_by_xpath('//label[@for="check54490"]').click()' is not a valid XPath expression.
(Session info: chrome=90.0.4430.85)