1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] SELENIUM FIND ELEMENT BY XPATH

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 10:13.

  1. Stack

    Stack Membro Participativo

    I have three elements with the same button class and span class names. I wanted to use xpath to select the second span class but I always get it wrong.

    I used:

    browser.find_element(By.XPATH, "/html/body/div[1]/div/div[3]/main/div[3]/div[2]/div[2]/div/div/section[2]/div[2]/form/div[9]/button/span[1]").click()


    But I get error. I also tried the following but get the same error message.

    result = browser.find_elements(By.XPATH, "//button[@class='_1h5on2Eq5J']")[2].click()

    browser.switch_to.frame(result)

    results = browser.find_element(By.XPATH, "/html/body/div[1]/div/div[3]/main/div[3]/div[2]/div[2]/div/div/section[2]/div[2]/form/div[9]/button/span[1]")


    Below is an excerpt of the html. My interest is to find the second element.

    [​IMG]

    Continue reading...

Compartilhe esta Página