Wrong context set when using within

オープン
#4,840 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
javascript, playwright
領域
testing-qa

調査の方向性

まず _getContext 関数と within の実装をたどり、次に提供されている modal の例を waitForEnabled とともに実行します。関連する waitForDisabled、waitNumberOfVisibleElements、waitForValue、waitForText の動作を確認します。within('.modal-dialog') が想定されるページまたはフレームのコンテキストを使用し、これらのヘルパーがブロック内でコンテキストエラーなしに動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
JavaScript
スター
4.2k
フォーク
756
平均マージ
2日 9時間
マージ済み PR(30日)
16

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codeceptjs/CodeceptJS のほかの issue

codeceptjs/CodeceptJS の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。