I am new to Selenium I have been following the documentations but they seem outdated.
(for curious people, that is the admin section of Atlassian's Cloud
What am I doing wrong? Note that I am using Edge webdriver if that matters.
Thanks.
EDIT: From first investigations, it seems that the the <label>
is overlapping the input.
If I indeed click on the label itself it does toggle the button.
In the page code above, I tested my code on the xpath driver.find_element(By.XPATH, "//label[@data-checked='true']").click()
but the thing is that there are several labels on the page that show a data-checked='true' property.
How to craft the xpath so that I select the label associated with that specific input. Basically mixing the "//label[@data-checked='true']" and //input[@value='123456789abcde'] xpaths.
CodePudding user response:
Since we have no access to that page we can only guess.
So, instead of driver.find_element(By.XPATH, "//input[@value='123456789abcde']").click()
Try adding a wait. The WebdriverWait is the preferred way to do that, as following:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@value='123456789abcde']"))).click()
UPD
In case you need to click the label
element which is a direct parent of this input
the locator can be updated as following:
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@value='123456789abcde']/.."))).click()
Another way to precisely locate that label
is to find the parent div
based on the child input
and from it to get the child label
as following:
wait.until(EC.element_to_be_clickable((By.XPATH, "//div[.//input[@value='123456789abcde']]//label"))).click()