简体   繁体   中英

Selenium Webdriver - Java - Get a specific text from Gmail

I'm trying to extract a specific text received from an Email sent after ending a flow. I need to fetch a code sent by Email to my Gmail account, but I'm not able to reach the xpath:

<b>87884</b>

The error is the next:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id=":13s"]/div[1]/div[2]/div[1]/div[1]/div[6]"}

I can't reach the element with xpath, id... No way!!!

Could you please help me?

This is a part of the HTML (There are no frames)

<div>
    <div>
        <div><h4>PLANTILLA DEPURACION DE RENTA</h4></div>
        <div><b>Estimado Colaborador,</b></div>
        <div>Favor validar renta adjunta.<br><br></div>
        <div>Al correo se adjuntan las ultimas tres(3) liquidaciones.<br><br></div>
        <div>
            <span><b>Ejecutivo solicitante: </b> Roberto JaimeAdasme  Vera</span><br>
            <span><b>Rut solicitante: </b>10032153K</span><br>
            <span><b>Renta Bruta Ejecutivo: </b>1228819</span><br>
            <span><b>Renta Liquida Ejecutivo: </b>1010044</span><br>
            <span><b>Renta Depurada Ejecutivo: </b>1228819</span><br>
            <span><b>Otros Descuentos: </b>112233</span><br>
            <span><b>Pmt: </b>69520</span><br>
            <span><b>Tipo de Campania: </b>Sin campaña</span><br>
            <span><b>Nombre Socio: </b>MICHAEL A JOSE</span><br>
            <span><b>Rut Socio: </b>135105899</span><br>
            <span><b>Fecha: </b>18/04/2018</span><br>
        </div>
        <br>
        <br>
        <br>
        <div>En caso de renta <span><b>valida</b></span> enviar el codigo <span style="font-size:20px"><b>87884</b></span> al ejecutivo.</div>
        <br>
        <div>En caso de renta <span><b>invalida</b></span> enviar correccion al ejecutivo.</div>
        <br>
        <br>
        <div>
            Este correo electronico contiene informacion legal confidencial y privilegiada.
            Si Usted no es el destinatario a quien se desea enviar este mensaje,
            tendra prohibido darlo a conocer a persona alguna, asi como a reproducirlo o
            copiarlo. Si recibe este mensaje por error, favor de notificarlo al remitente
            de inmediato y desecharlo de su sistema.
        </div>
        <br>
        <div>Los acentos han sido omitidos por motivos de compatibilidad.</div><div class="yj6qo"></div><div class="adL">
    </div></div><div class="adL">
</div></div>

in the html code I don't see <b>87884</b>

Maybe better to find list of elements by xpath and get the desired one by index.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM