Wrong context set when using within
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, playwright
- Área
- testing-qa
Línea de trabajo
Empieza siguiendo la función _getContext y la implementación de within, y luego ejecuta el ejemplo de modal proporcionado con waitForEnabled. Comprueba el comportamiento relacionado de waitForDisabled, waitNumberOfVisibleElements, waitForValue y waitForText. Se considera terminado cuando within('.modal-dialog') usa el contexto de página o frame esperado y estos helpers funcionan dentro del bloque sin errores de contexto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
After updating to CodeceptJS version 3.6.10 (also occurring in 3.7.0), we noticed that the within functionality no longer works correctly when used with a selector like .modal-dialog. Instead of setting the context to a page or frame object, it sets it to a locator object, which causes an error when trying to execute certain functions.
The error encountered:
context.waitForFunction is not a function
This error occurred in the waitForEnabled function, which expects context to be a page object, but instead it is passed as a locator because of the changes introduced with: #4557
Other helper functions that we found that produce the same error: waitForDisabled, waitNumberOfVisibleElements, waitForValue.
We also observed other functions like waitForText not working correctly inside within (e.g. not finding text inside the within context although it was obviously there).
Specifically this line in the _getContext function breaks this use case, since it now returns this.context even if it is a locator object:
async _getContext() {
if ((this.context && this.context.constructor.name === 'FrameLocator') || this.context) {
return this.context
}
...
Everything worked fine again after reverting the changes that were introduced by this commit.
Steps to Reproduce
- Use the
withinfunction with a selector such as.modal-dialog. - Attempt to run a command inside the
withinblock, likewaitForEnabled. - Observe the error message.
Example test case:
Feature('Modal Test');
Scenario('Test modal within', async ({ I }) => {
I.amOnPage('https://example.com');
I.click('.open-modal');
within('.modal-dialog', async () => {
I.waitForEnabled('.button')
});
});
Details
- CodeceptJS version: 3.6.10 and 3.7.0
- NodeJS Version: 23.7.0
- playwright-core version: 1.49.1
- Lenguaje dominante
- JavaScript
- Estrellas
- 4.2k
- Forks
- 756
- Merge medio
- 2 d 9 h
- PR fusionados (30 d)
- 16
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de codeceptjs/CodeceptJS
-
stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
codeceptjs/CodeceptJS#5420 · 1 comentario ·
-
stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
codeceptjs/CodeceptJS#5358 · 1 comentario ·
-
stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
codeceptjs/CodeceptJS#4958 · 10 comentarios · 2 reacciones ·
-
stale
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
codeceptjs/CodeceptJS#4778 · 3 comentarios ·
-
stale
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
codeceptjs/CodeceptJS#5618 · 1 comentario ·
Todos los issues de codeceptjs/CodeceptJS
Issues similares
-
ai-observability bug team/ai-observability
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
AllTheMods/ATM-10-L#19 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SignalK/n2k-signalk#345 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
JuliaPluto/PlutoPlotly.jl#72 ·