I can click all of the other check boxes on the page. But when it comes to this one, it won't allow me to click on it
我可以单击页面上的所有其他复选框。但是当涉及到这个时,它不允许我点击它
The html code for the check box it
它的复选框的html代码
<input id="ContentPlaceHolder1_wucSignInStep2_chkTC" type="checkbox" name="ctl00$ContentPlaceHolder1$wucSignInStep2$chkTC">
My code for clicking the text box:
我点击文本框的代码:
element = driver.find_element_by_xpath('//span[span/input[@name="checkbox checkbox-primary"]]').click()
I can provide the full code if required
如果需要,我可以提供完整的代码
1 个解决方案
#1
0
There is an id
associated with your input field! You can use the id to find the element
您的输入字段有一个ID!您可以使用id来查找元素
element = driver.find_element_by_id('ContentPlaceHolder1_wucSignInStep2_chkTC').click()
That should do it.
应该这样做。
If you are getting an element not visible
error then you can try the following:
如果您获得的元素不可见错误,那么您可以尝试以下方法:
from selenium.webdriver.common.action_chains import ActionChains
element = driver.find_element_by_id("ContentPlaceHolder1_wucSignInStep2_chkTC")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
driver.execute_script("arguments[0].click();", element)
The above code will make the element visible and also, put the mouse cursor over the checkbox.
上面的代码将使元素可见,并将鼠标光标放在复选框上。
#1
0
There is an id
associated with your input field! You can use the id to find the element
您的输入字段有一个ID!您可以使用id来查找元素
element = driver.find_element_by_id('ContentPlaceHolder1_wucSignInStep2_chkTC').click()
That should do it.
应该这样做。
If you are getting an element not visible
error then you can try the following:
如果您获得的元素不可见错误,那么您可以尝试以下方法:
from selenium.webdriver.common.action_chains import ActionChains
element = driver.find_element_by_id("ContentPlaceHolder1_wucSignInStep2_chkTC")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
driver.execute_script("arguments[0].click();", element)
The above code will make the element visible and also, put the mouse cursor over the checkbox.
上面的代码将使元素可见,并将鼠标光标放在复选框上。