Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Click don't working for enabled element in Selenium

I want that some element on page has been clicked. But Selenium click doesn't working. This part of my code:

username_form = driver.find_element_by_id('form3-username')
    password_form = driver.find_element_by_id('form3-password')
    username_form.send_keys('SomeLogin')
    password_form.send_keys('SomePass')
    driver.find_element_by_xpath("//div[@class='one-factor']/button").click()
    element = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH,  "//div/a[@id='notify-toggle' and not(@disabled)]"))
    )
    element.click()

and part the page I'm processing:

<a id="notify-toggle" class="toggle link">
    <span title="Уведомления" class="data-count" data-count="0" data-icon="">
    </span>
</a>

Promlem is element.click() doesn't working. i got acquainted with some solution of my problem, but that I find didn't work for me. I trying use xpath expression with not (@disabled) and other solutions, but no one was helpful for me. I have no idea whatsoever why click is not working and I'll be glad to any hints

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Target the inner <span> inducing WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.toggle.link#notify-toggle span.data-count:not(disabled)[title][data-icon]"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='toggle link' and @id='notify-toggle']//span[@class='data-count' and @title][@data-icon and not(@disabled)]"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

References

You can find a couple of relevant detailed discussions in:

  • How to find elements that do not include a certain class name with selenium and python
  • While fetching all links,Ignore logout link from the loop and continue navigation in selenium java
  • Protractor - Check if a radio-button is checked or not
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda