0

I can't find an element and get an error, but I actually see it when inspecting the element, but if I "print" driver.page_source I can't see it.

def screenname():
   driver.find_element(By.XPATH, '//*[@id="indium_view_form_BooleanCheckBox_1"]').click()

screenname()

#also tried ID and CSS Selector
#THE CODE I SEE FROM INSPECTING THE ELEMENT
#<input name="nameTransposition" type="checkbox" role="checkbox" aria-checked="false" class="dijitReset dijitCheckBoxInput" data-dojo-attach-point="focusNode" data-dojo-attach-event="ondijitclick:_onClick" value="on" tabindex="0" id="indium_view_form_BooleanCheckBox_1" style="user-select: none;">

This is the error I get

#selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="indium_view_form_BooleanCheckBox_1"]"}

Click on the element

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Maybe it's not loaded yet? Try to wait until this element shows up

from selenium.webdriver.support.wait import WebDriverWait

element = WebDriverWait(driver=driver, timeout=timeout).until(
            method=expected_conditions.presence_of_element_located(
              locator=(
                By.XPATH,
                """//*[@id="indium_view_form_BooleanCheckBox_1"]""",
              ),
            )
          )
element.click()
Artem Strogin
  • 176
  • 1
  • 6