Wrong context set when using within
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- javascript, playwright
- Bereich
- testing-qa
Rechercherichtung
Beginne damit, die Funktion _getContext und die Implementierung von within nachzuverfolgen, und führe dann das bereitgestellte modal-Beispiel mit waitForEnabled aus. Überprüfe das Verhalten der verwandten Funktionen waitForDisabled, waitNumberOfVisibleElements, waitForValue und waitForText. Als erledigt gilt die Aufgabe, wenn within('.modal-dialog') den erwarteten Seiten- oder Frame-Kontext verwendet und diese Helfer innerhalb des Blocks ohne Kontextfehler funktionieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- JavaScript
- Sterne
- 4.2k
- Forks
- 756
- Ø Merge
- 2 T. 9 Std.
- Gemergte PRs (30 T.)
- 16
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codeceptjs/CodeceptJS
-
stale
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
codeceptjs/CodeceptJS#5420 · 1 Kommentar ·
-
stale
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
codeceptjs/CodeceptJS#5358 · 1 Kommentar ·
-
stale
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
codeceptjs/CodeceptJS#4958 · 10 Kommentare · 2 Reaktionen ·
-
stale
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
codeceptjs/CodeceptJS#4778 · 3 Kommentare ·
-
stale
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
codeceptjs/CodeceptJS#5618 · 1 Kommentar ·
Alle Issues in codeceptjs/CodeceptJS
Ähnliche Issues
-
bug confirmed issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
open-webui/open-webui#30750 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Mend: dependency security vulnerability untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100