Skip to content
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

[BUG] Unable to switch frames when using chromium #2292

Closed
saurabhxkapoor opened this issue May 19, 2020 · 10 comments
Closed

[BUG] Unable to switch frames when using chromium #2292

saurabhxkapoor opened this issue May 19, 2020 · 10 comments

Comments

@saurabhxkapoor
Copy link

saurabhxkapoor commented May 19, 2020

Context:

  • Playwright Version: 1.0.2
  • Operating System: Mac
  • Node version: 10.15.2
  • Browser: chrome (works on firefox and webkit)
  • Extra: used to work with playwright v 0.9.21

Code Snippet

selectFrame: async function(frameName) {
        console.log('switching frame..');
        frame = await page.frames().find((frame) => frame.name() === frameName);
        page = await frame;
        console.log(page);

    },

This results in undefined page

console.log src/client/__tests__/BrowserTestUtils.js:61
    switching frame..

  console.log src/client/__tests__/BrowserTestUtils.js:64
    undefined

This is working with playwright version 0.9.21

@pavelfeldman
Copy link
Member

It looks like there is no frame with the given name.

I am not sure assigning frame to a page is what you want here - these are objects of different types. You will be calling Page methods on this object and it won't have them because it would be a frame, not a page.

Note that you only need to await promises, so both awaits in your snippet are not necessary and the whole function can be synchronous.

Also note that unlike with Selenium, you don't need to "switch" frames, you can work with them simultaneously and it is recommended to pass the frame object into functions that operate on a given frame.

@pavelfeldman
Copy link
Member

The fact that it works on WebKit and Firefox could be due to a race condition. You might need to wait for the frame to be attached/loaded in the page before you access it.

@saurabhxkapoor
Copy link
Author

saurabhxkapoor commented May 19, 2020

@pavelfeldman - we pass frame name to this method. Due to the complexity of our application - we have to assign frame to a page which has majority of the testable components.
This used to work on Playwright v0.9.21 (on all browsers) and works on puppeteer currently.

I am seeing issue with chromium only on the latest playwright version (1.0.2)

@pavelfeldman
Copy link
Member

Our tests for this feature pass on all the platforms, so I wonder if there is something specific in your environment. Is this frame served off the same origin as the page? We might be facing an out-of-process iframe in Chromium if it isn't. Happy to resolve this for you, but need help reproducing.

@saurabhxkapoor
Copy link
Author

@pavelfeldman - we serve part of the landing frame that is not recognized from foo.company.com and load/log into bar-test.company.com.. so it isn't the same origin because of different subdomains

@pavelfeldman
Copy link
Member

Got it. Since those are same domain, they should be considered same-site by Chromium, so no out-of-process-iframe business. Then it must be the race condition - there is no frame with that name at the moment you are asking. You get lucky with non-Chromium, but that luck might flake.

@pavelfeldman
Copy link
Member

Anything we can do to repro? Did you figure out whether it was a race on your side?

@saurabhxkapoor
Copy link
Author

@pavelfeldman - doesn't seem to be a race condition. It is happening only on chromium (and not on firefox and webkit). Due to security of the application, it is difficult to post more details here.

@shirshak55
Copy link

shirshak55 commented May 29, 2020

@saurabhxkapoor well playwright team needs reproduction and tests are passing so there is nothing they can do on their end. And before assigning can u do console log etc?

await page.frames().find((frame) => { 
 console.log(frame,frame.name());
 return frame.name() === frameName
});

@pavelfeldman
Copy link
Member

Unfortunately, we haven't seen it happening anywhere. And since the name of the bug includes "switch frames", which does not really apply to Playwright, I'll tentatively close this as a part of my bulk triage. Could you please open a new bug suggesting the certain frame is missing if you find a repro scenario you can share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants