Wrong context set when using within
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, playwright
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu bằng cách lần theo hàm _getContext và phần triển khai của within, sau đó chạy ví dụ modal được cung cấp cùng với waitForEnabled. Kiểm tra hành vi liên quan của waitForDisabled, waitNumberOfVisibleElements, waitForValue và waitForText. Hoàn tất khi within('.modal-dialog') sử dụng đúng context của page hoặc frame và các helper này hoạt động bên trong block mà không có lỗi context.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 4.2k
- Fork
- 756
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 16
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codeceptjs/CodeceptJS
-
stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
codeceptjs/CodeceptJS#5420 · 1 bình luận ·
-
stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
codeceptjs/CodeceptJS#5358 · 1 bình luận ·
-
stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
codeceptjs/CodeceptJS#4958 · 10 bình luận · 2 reaction ·
-
stale
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
codeceptjs/CodeceptJS#4778 · 3 bình luận ·
-
stale
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
codeceptjs/CodeceptJS#5618 · 1 bình luận ·