Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

411
Vistas
Error: DeprecationWarning: Unhandled promise rejections are deprecated. - Promises in Javascript with Selenium

I am trying to set up some test cases with Selenium in Javascript for a simple login page test. I am at the point where I am trying to set up proper error catching by rejecting within a Promise. Here is my Promise code:

//Test Case 1: Valid Email / Valid Password
async function tc1() {
    announceTC();
    //Create promise to handle execution of async test case
    let promise = new Promise(async function (resolve, reject) {
        //Create the webdriver (Chrome) and open an instance of the test page
        const driver = createDriver();

        //Enter valid email / valid password
        await validEmail(driver, reject);
        await validPassword(driver);

        //Click login button
        await clickLoginButton(driver);

        //Test for a successful login
        await testSuccessfulLogin(driver, resolve, reject);

        //Exit the driver instance.
        await driver.quit();

        //Trigger the callback functions
        promise
            .then(value => console.log(value),
                value => console.log(value))
            .catch(value => console.log(value))
            .finally(() => tc2());
    });
};

Within my validEmail function, I am trying to reject if an error occurs. Here is my code for that function:

//Find and enter valid email on login page
async function validEmail(driver, reject) {
    try{
        //Click email input box.
        let emailBox = await driver.wait(until.elementLocated(By.xpath("//*[@id='email']/iput")), 5000);
        await emailBox.click();

        //Input email.
        driver.findElement(By.xpath("//*[@id='email']/input")).sendKeys("redacted@gmail.com");
    } catch(error) {
        console.log(error);
        reject(tcErrorMsg());
    }
}

My understanding of this error, is that it occurs when you do not provide a catch on the promise to handle a rejected case.

My testSuccessfulLogin function uses resolve and the promise runs through .then properly, so I am unsure why I am getting an unhandled rejection error when I use reject in the same way.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

below code should be moved outside the async function

 //Trigger the callback functions
        promise
            .then(value => console.log(value),
                value => console.log(value))
            .catch(value => console.log(value))
            .finally(() => tc2());
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda