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

190
Visualizações
Facing error TypeError: cannot read property 'script' of undefined

I am learning Nightwatch. When I am executing the below I am facing error.I want to edit my script.js file to fix error but I am not sure what to do. Where my test.js file is

module.exports = {


     'Login': function (client) {
          client.page.script()
               .launchapp()
               .collection()
               .Checkdata()
               .notravel()
               .avail()
     },


};

And my script.js file is

const commands = {
    launchapp: function () {
        return this.init()
    },

    collection: function () {
        return this.click('@city')
            .waitForElementPresent('@cityInput')
            .setValue('@cityInput', 'hyd')
            .waitForElementPresent('@firstOption')
            .click('@firstOption')
    },
    Checkdata: function () {
      return this.waitForElementPresent('@checkin')
       .click('@checkin')
       .useXpath()
       .waitForElementPresent(`(//table[@class=' table-condensed']//tbody//tr//td[text()='2'])[1]`)
       .click(`(//table[@class=' table-condensed']//tbody//tr//td[text()='4'])[1]`)
       .useXpath()
       .click("//span[text()='Checkout']")
       .click("//input[@name='checkout']")
       .waitForElementPresent(`(//table[@class=' table-condensed']//tbody//tr//td[text()='3'])[2]`)
       .click(`(//table[@class=' table-condensed']//tbody//tr//td[text()='6'])[2]`)
       .click(`(//label[text()='Travellers']/parent::div/div/div/a)[1]`)

           
    },
    notravel: function () {
        //  some code goes here
        return this;
    },
     avail: function () {
        //  some code goes here
        return this.useXpath().click(`(//button[@id='submit']//span[text()=' Search'])[1]`)
    },
}
module.exports = {
commands: [commands],
elements: {
        city: '#select2-hotels_city-container',
        cityInput: "input[aria-controls='select2-hotels_city-results']",
        firstOption: "#select2-hotels_city-results li",
        checkin: '#checkin',
        checkOut: "#checkout"
    },
}

When I am executing this I am facing error either "Cannot read property 'script' undefined" or "Cannot read property 'page' undefined"

Kindly help me on this.

about 4 years ago · Juan Pablo Isaza
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