Coder Social home page Coder Social logo

Comments (5)

yury-s avatar yury-s commented on May 14, 2024

Because the default behavior for context.newPage() seems to be to create a tab to about:blank first, I'm not able to test the first scenario (at least, not without some workaround--still learning what's available in Playwright).

This is consistent with user<->browser interaction, the user first opens a new tab and then types in the url. The only case it is different is when a new tab is opened by existing page, e.g. when the user clicks on a link with target=_blank. Both of these cases are supported in playwright, you can listen to the new pages via context.on('page') or page.on('popup'). Do these page events not work in your scenario?

from playwright.

yury-s avatar yury-s commented on May 14, 2024

Closing this request as we are not planning to change the newPage() api.

from playwright.

tbrockman avatar tbrockman commented on May 14, 2024

The only case it is different is when a new tab is opened by existing page, e.g. when the user clicks on a link with target=_blank

Or when the user right-clicks a link and selects "Open in New Tab", or selects "Open in New Window", or uses a shortcut like middle mouse clicking...

As you have described, this restricts the ability to simulate the full range of user behavior. There is a meaningful distinction (to my application and in general) between a user performing a navigation by opening a new tab to a link directly without creating any previous history in the new tab, and manually creating a new tab and then performing a navigation in it. This is unnecessarily restrictive, particularly when the underlying tooling already provides you the option to do so.

from playwright.

yury-s avatar yury-s commented on May 14, 2024

Or when the user right-clicks a link and selects "Open in New Tab", or selects "Open in New Window", or uses a shortcut like middle mouse clicking...

All of these scenarios can be performed by executing Ctrl+click, Shift+click etc using Locator.click() with modifiers. You can listen for the new pages using the events I mentioned above.

from playwright.

tbrockman avatar tbrockman commented on May 14, 2024

Okay, I can see how that can be could be used to satisfy some of the state that I'm wanting to test, thanks for the link to the doc.

Is there anything similarly available to simulate the event of restoring a browser session? I would assume that this would also be equivalent to opening many pages and directly navigating to a given URL.

from playwright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.