Reputation: 129
I'm using Selenium
Python
to do the same action for different users and the flow is as follows,
1- the webpage show list of user ids 2- I search for 1 user-id (Iteration) 3- I click on the check box next to the user-id 4- I click on done
My issue is with the check box, it is clickable in the first row of iteration but then it becomes unclickable with the next row.
Checkbox Element:
<input type="checkbox" class="ant-checkbox-input" value="" xpath="1">
I have also tried ActionChains
but I got the error: stale element reference: element is not attached to the page document
Thank you
Upvotes: 1
Views: 41
Reputation: 26
the input checkbox might be in disable state or some javascript load is yet to happen before checkbox become availabe.
try this code:
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH,"//tbody/tr[1]/td[1]/span[1]/label[1]/span[1]/input[1]"))).click()
another problem might be xpath changes depending on user you logged in.
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH,'//input [@type="checkbox"]'))).click()
above code will work only if you have 1 checkbox.
This code will try to click all the check boxes present on page, if this works we could narrow down XPath.
els=driver.find_elements_by_xpath('//input [@type="checkbox"]')
for el in els:
try:
el.click()
except:
pass
Upvotes: 1