Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda