Skip to content

fix: switchTo - within block #3892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 9, 2023
2 changes: 1 addition & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ class Playwright extends Helper {

// get content of the first iframe
locator = new Locator(locator, 'css');
if ((locator.frame && locator.frame === 'iframe') || locator.value.toLowerCase() === 'iframe') {
if ((locator.frame && locator.frame === 'iframe') || locator.value.toLowerCase() === 'iframe' || locator.value.toLowerCase().includes('iframe')) {
contentFrame = await this.page.frames()[1];
// get content of the iframe using its name
} else if (locator.value.toLowerCase().includes('name=')) {
Expand Down
7 changes: 7 additions & 0 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ describe('Playwright', function () {
I.switchTo(null);
I.see('Iframe test');
});

it('should switch to iframe using css', async () => {
I.amOnPage('/iframe');
I.switchTo('iframe#number-frame-1234');
I.see('Information');
I.see('Lots of valuable data here');
});
});

describe('#seeInSource, #grabSource', () => {
Expand Down