codeceptjs / codeceptjs/CodeceptJS

Codeceptjs test fails on click but it clicks

Abierto
#2,683 2 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
4.2k
Forks
757
Merge medio
2 d 9 h
PR fusionados (30 d)
16

Descripción

#### 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.

```js
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

```js

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

* CodeceptJS version:
* NodeJS Version: v12.19.0
* Operating System: Ubuntu 20.04.1 LTS
* webdriverio
* Configuration file:

```js
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:

```js
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);
},

}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.