codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 723 forks source link

Codeceptjs test fails on click but it clicks #2683

Open ChilinaDP opened 3 years ago

ChilinaDP commented 3 years ago

What are you trying to achieve?

I click an element y test fails, but when you see the screenshots the click was made. Test sees the element exits before clicking it.

What do you get instead?

Error can't found element

Provide console output if related. Use --verbose mode for more details.

Clickable element ".btn-primary" was not found by text|CSS|XPath

  Scenario Steps:

  - I.click(".btn-primary") at Object.login (steps_file.js:26:12)
  - I.wait(2) at Object.login (steps_file.js:25:12)
  - I.seeElement(".btn-primary") at Object.login (steps_file.js:24:12)
  - I.fillField("#j_password", "A1b2c3d4") at Object.login (steps_file.js:23:12)
  - I.fillField("#j_username", "pruebaqa.maks@gmail.com") at Object.login (steps_file.js:22:12)
  - I.amOnPage("/login") at Object.login (steps_file.js:21:12)

  Error: Clickable element ".btn-primary" was not found by text|CSS|XPath
      at new ElementNotFound (node_modules/codeceptjs/lib/helper/errors/ElementNotFound.js:14:11)
      at assertElementExists (node_modules/codeceptjs/lib/helper/WebDriver.js:2675:11)
      at WebDriver.click (node_modules/codeceptjs/lib/helper/WebDriver.js:839:7)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

Provide test source code if related


module.exports = function() {

  return actor({

    login: function() {
      this.amOnPage('/login');
      this.fillField('#j_username', "pruebaqa.maks@gmail.com");
      this.fillField('#j_password', "A1b2c3d4");
      this.seeElement('.btn-primary');
      this.wait(2);
      this.click('.btn-primary');
      this.wait(2);
    }
  });
}

Details

exports.config = {
  output: './output',
  helpers: {
    WebDriver: {
      url: 'https://zerca.com/',
      browser: 'chrome',
      smartWait: 5000,
      restart: false,
      windowSize: "maximize",
      keepBrowserState: false,
      keepCookies: false,
      timeouts: {
        script: 70000,
        "page load": 15000
      },
    },
      customHelper: {
        require: './resources/CustomHelper.js',
      },
  },
  include: {
    I: './steps_file.js',
    //Marketplace   
    homePage: './pages/marketplace/Home.js',    
    headerPage: './pages/marketplace/Header.js',
    cestaPage: './pages/marketplace/Cesta.js',
    productoPage: './pages/marketplace/Producto.js',
    registroPage: './pages/marketplace/Registro.js',

    //PageObject Backoffice    
  },
  mocha: {},
  bootstrap: null,
  teardown: null,
  hooks: [],
  gherkin: {
    features:
      './features/**/*.feature',
    steps: [
      // Marketplace
     // Header
     "./step_definitions/marketplace/Header/steps_precabecera.js",
     "./step_definitions/marketplace/Header/steps_logotipo.js",
     "./step_definitions/marketplace/Header/steps_buscador.js",
     "./step_definitions/marketplace/Header/steps_cesta_header.js",
     "./step_definitions/marketplace/Header/steps_identificacion_registro.js",
     "./step_definitions/marketplace/Header/steps_aumentarCantidadCarrito.js",
     "./step_definitions/marketplace/Header/steps_disminuirCantidadCarrito.js",
     "./step_definitions/marketplace/Header/steps_eliminarCarrito.js",
     "./step_definitions/marketplace/Header/steps_verCarro.js",
     // Home
     "./step_definitions/marketplace/Home/steps_home.js",
     // Cesta
     "./step_definitions/marketplace/Cesta/steps_cesta.js",
     "./step_definitions/marketplace/Cesta/steps_aumentarCantidadCesta.js",
     "./step_definitions/marketplace/Cesta/steps_disminuirCantidadCesta.js",
     "./step_definitions/marketplace/Cesta/steps_eliminarCesta.js",
     "./step_definitions/marketplace/Cesta/steps_saldoAcumulado.js",
     "./step_definitions/marketplace/Cesta/steps_seguirComprando.js",
     "./step_definitions/marketplace/Cesta/steps_tramitarPedido.js",
     // FichaProducto
     "./step_definitions/marketplace/FichaProducto/steps_cestaProducto.js",
     "./step_definitions/marketplace/FichaProducto/steps_seleccionCantidad.js",
     "./step_definitions/marketplace/FichaProducto/steps_carrouseles.js",
     // RegistroUsuario
     "./step_definitions/marketplace/Registro/steps_registro.js",
     // Backoffice  
    ]
  },
  plugins:   {
    allure: {
      enabled: true,
      outputDir: "report",
    },
    stepByStepReport: {
      enabled: true,
      screenshotsForAllureReport: false
    },
    screenshotOnFail: {
      enabled: true
    },
    retryFailedStep: {
      enabled: true,
      minTimeout: 5000,
    },
    wdio: {
      enabled: true,
      services: ['selenium-standalone']
    },
    selenoid: {
      enabled: true,
      deletePassed: true,
      autoCreate: false,
      autoStart: true,
      sessionTimeout: '30m',
      //enableVideo: true,
      //enableLog: true,
      enableVNC: true
    },
  },
  tests: './*_test.js',
  name: 'zerca-validation-test'
}

I have the same issue in the same project, but other feature

Code:

const { I } = inject();

module.exports = {

  // insert your locators and methods here

  botones: {
    facebook: '.facebook-login button',
  },

// Entrar con RRSS

  clicarFacebook () {
    I.waitForClickable(this.botones.facebook);
    I.click(this.botones.facebook);
  },

}
gkushang commented 3 years ago

I face the same issue

UmangThapliyal commented 3 years ago

does anyone know why it happens, I am facing the same issue