Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Webdriver.io: problemas al cambiar a una nueva ventana/pestaña

Estoy usando Webdriver.io/Nodejs/Mocha y cuando trato de cambiar de la pestaña principal a la pestaña secundaria, la mayoría de las veces funciona; sin embargo, hay momentos en que la pestaña tardará mucho en cargarse debido a problemas/anuncios incorrectos en la página y durante esos momentos, aunque obtengo el GUID de la ventana/pestaña, todavía no cambia y permanece en el padre pestaña. No sucede todo el tiempo, pero de vez en cuando no cambia.

¿La página tiene que cargarse por completo para poder cambiar a la pestaña chid? ¿Me estoy perdiendo algo? Cualquier ayuda sería apreciada. ¡Gracias!

  • Versión del nodo: v16.13.1
  • Versión de WebdriverIO: 7.16.12
  • Versión moca: 9.0.0
  • Versión del controlador Chrome: 95.0.0

Ejecución:

 npx mocha --config ./mocharc.json ./test/test.js

Archivo de prueba: test.js

 it('Test Case: Switch Tabs', async () => { let parentGUID; let childGUID; // get parent GUID parentGUID = await this.driver.getWindowHandle(); // click element to launch new tab await this.driver.elementClick('//a[@id="test"]'); // wait until new tab loads await this.driver.pause(2000); // get all GUID's const allGUIDs = await this.driver.getWindowHandles(); // check all GUID's and see which one is the child for (let i = 0; i < allGUIDs.length; i++) { if (allGUIDs[i] !== parentGUID) { childGUID = allGUIDs[i]; } } // switch to child tab await this.driver.switchToWindow(childGUID); // assert content on the new page here // ... // ... // ... // close tab await this.driver.closeWindow(); // switch to parent window/tab await this.driver.switchToWindow(parentGUID); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto parece un simple error de codificación. Mientras inicia su parentGUID, no le asigna ningún valor. Luego lo está usando para comparar en su bucle for. A veces, el GUID secundario se asigna con el GUID primario. En este caso, el cambio parece no estar sucediendo. Lo he corregido a continuación.

 it('Test Case: Switch Tabs', async () => { let childGUID; // get parent GUID const parentGUID = await this.driver.getWindowHandle(); // click element to launch new tab await this.driver.elementClick('//a[@id="test"]'); // wait until new tab loads await this.driver.pause(2000); // get all GUID's const allGUIDs = await this.driver.getWindowHandles(); // check all GUID's and see which one is the child for (let i = 0; i < allGUIDs.length; i++) { if (allGUIDs[i] !== parentGUID) { childGUID = allGUIDs[i]; } } // switch to child tab await this.driver.switchToWindow(childGUID); // assert content on the new page here // ... // ... // ... // close tab await this.driver.closeWindow(); // switch to parent window/tab await this.driver.switchToWindow(parentGUID); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!