how to click a chor in Selenium Webdriver (python)

Asked

Viewed 192 times

1

I tried to click an chor to return a value inside my input;

I tried using the Xpath and the link_text to click on it.

How could I do that ?

Python code:

    window_segundo = driver.window_handles[1]
    driver.switch_to.window(window_segundo)
    user_element = driver.find_element_by_xpath('//*[@id="id_Arg"]').send_keys('12', Keys.ENTER)
    user_element = driver.find_element_by_link_text("88319561000107").click()  

Element:

<td class="linha">
        <a href="#" onclick="devolveSelecao('operadora#12,descOperadora#SOGAL,limpaArg#,limpaArg2#,limpaArg3#,limpaArg4#,limpaArg5#,limpaArg6#,versaoFw#,ultimaCarga#,descSituacaoEquipamento#,descTipoEquipamento#,descTipoVeiculo#,numSD#,veiculoAtual#,numSDAtual#,tipoVeiculoAtual#');">88319561000107</a>
</td>

Error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"88319561000107"}

inserir a descrição da imagem aqui

  • you gave switch when he opened this popup window? if not he will be looking for it there in the previous window

  • yes I gave the switch after the popup and did the values search, it worked perfectly, only when I click on these values it does not locate.

  • the command, find_element_by_link_text does not serve to pick up the text between the tags, it will usually pick up the text from within the tag, ex: <a href="www.etc.com" title="88319561000107"> (in this case it would work), you can pick up by xpath like this: //a[text()='88319561000107']

  • Lucas I do not know the pq but at some point he kind of got lost on the switch, so I gave a switch to return the main screen and one more to return to this popup, then I could find the element using Xpath. I really appreciate your help...

No answers

Browser other questions tagged

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