Wrong context set when using within
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- javascript, playwright
- Domínio
- testing-qa
Direção de pesquisa
Comece rastreando a função _getContext e a implementação de within e, em seguida, execute o exemplo de modal fornecido com waitForEnabled. Verifique o comportamento relacionado de waitForDisabled, waitNumberOfVisibleElements, waitForValue e waitForText. Está concluído quando within('.modal-dialog') usa o contexto de página ou frame esperado e esses helpers funcionam dentro do bloco sem erros de contexto.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- JavaScript
- Estrelas
- 4.2k
- Forks
- 756
- Merge médio
- 2d 10h
- PRs com merge (30d)
- 18
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de codeceptjs/CodeceptJS
-
stale
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
codeceptjs/CodeceptJS#5420 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
stale
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
codeceptjs/CodeceptJS#5358 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
stale
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
codeceptjs/CodeceptJS#4958 · 10 comentários · 2 reações ·
Mantenedores costumam responder em até 2 dias
-
stale
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
codeceptjs/CodeceptJS#4778 · 3 comentários ·
Mantenedores costumam responder em até 2 dias
-
stale
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
codeceptjs/CodeceptJS#5618 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
Todas as issues de codeceptjs/CodeceptJS
Issues semelhantes
-
status: waiting triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
freeCodeCamp/freeCodeCamp#70412 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Jason-Vaughan/TangleClaw#1884 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue web
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/TypeScript#64453 ·
Mantenedores costumam responder em até 1 dia
-
self-driving
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia