Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Wrong context set when using within

Aberta
#4,840 1 comentário 0 reações 0 responsáveis Ver no GitHub

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

stale

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

  1. Use the within function with a selector such as .modal-dialog.
  2. Attempt to run a command inside the within block, like waitForEnabled.
  3. 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

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de codeceptjs/CodeceptJS

Todas as issues de codeceptjs/CodeceptJS

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.