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

130
Vistas
Webdriverio check content from every page

I am trying to do an automatic test to check if a search bar works properly. My problem is that after I search I get not one, but a lot of different pages and I need to check if every item for every page matches the criteria. The question is: how to iterate over each page to check them all?

See code below:

search.page.js

    
const Page = require('./page');
 
class SearchResultsPage extends Page {
 
    get propertyLocation() {
        return $$('[aria-label="Location"]');
    }
 
    get pages() {
        return $$('[title*="Page"]');
    }
 
    get btnNextPage(){
        return $('[title="Next"]');
    }
 
    open() {
        return super.open('/for-sale/property/dubai/dubai-marina/');
    }
 
    open_page(page_index) {
        return super.open('/for-sale/property/dubai/dubai-marina/page-' + str(page_index));
    }
}
 
module.exports = new SearchResultsPage();

test.e2e.js

 const pages = await SearchResultsPage.pages
        console.log('here before');
        console.log(pages)
        pages.forEach(page => {
            console.log("i am here");
            page.click();
        });

wdio.conf.js

exports.config = {
    specs: [
        './test/specs/**/*.js'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
    maxInstances: 10,
    
    capabilities: [{
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true
    }],
    logLevel: 'info',
    bail: 0,
    baseUrl: 'https://www.bayut.com/',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services: ['chromedriver'],
    framework: 'mocha',
    reporters: ['spec'],
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },
}

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

0

If I understand well, you want to loop between pages. You can do that with a while loop and store the information you want into an array. You can have a method hasNextButton() that returns a boolean if next btn is present.

For example:

   while (searchPage.hasNextButton()) {
        // do anything you want 
        list.push(item.getText());
        
        searchPage.clickNextBtn();
    }
 

or if you want a certain number of pages:

   let pageNumber = 1;

   while (pageNumber <= totalPages) {
        // do anything you want 
        list.push(item.getText()); 

        searchPage.clickNextBtn();
        pageNumber++;
    }

After you have the information stored, you can process it however you want.

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