How to click a button using Selenium in Python?

Asked

Viewed 822 times

-1

I have these codes and I want to click the button Ver link, but I can’t because it’s a div.

If you use the submit he skips the task.

    <div class="btn_site"><br>
        <div class="btn-dizu bg-orange sombra marginT1 Bradius5 pularTarefa"><br>
            <button type="submit"><br>
                <p class="padd1 paddL3 paddR3 text_white">Pular Tarefa</p>
            </button><br>
        </div><br>
        <div class="btn-dizu bg-white sombra border1Grey Bradius5"><br>
            <a href="https://instagram.com/zhuleeeee" id="conectar_step_4" target="_blank"><br>
                <p class="padd1 paddL3 paddR3 text_black">Ver link</p>
            </a><br>
        </div><br>
        <div class="btn-dizu bg-blue sombra marginT1 Bradius5 d-none" id="conectar_step_5"><br>
            <button type="submit"><br>
                <p class="padd1 paddL3 paddR3 text_white">confirmar</p>
            </button><br>
        </div><br>
    </div><br>

1 answer

1


Hello!

Essa tarefa pode ser feita em 3 formas diferentes:
Usando :Id
Usando :  Nome da classe
Usando : XPath

from selenium import webdriver

driver = webdriver.Chrome("driver...")
driver.get('pagina')

clicar0 =  driver.find_element_by_id(" ?? ").click()
clicar1 = driver.find_element_by_name(" ?? ").click()
clicar2 = driver.find_elements_by_xpath(" ?? ").click()


Todas precisam de uma referencia seja pelo id da tag do botão ou nome da classe ou o xptah.

Utilitarian

  • I took the xpath from the div and it worked super well thanks friend

Browser other questions tagged

You are not signed in. Login or sign up in order to post.