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

Suggestion for Enhancing Chrome Extension Integration in Playwright #2263

Closed
Chetan11-dev opened this issue Jan 26, 2024 · 3 comments
Closed

Comments

@Chetan11-dev
Copy link

Let us know what functionality you'd like to see in Playwright and what your use case is?

  • I would like to suggest an update for the Playwright documentation, specifically at https://playwright.dev/python/docs/chrome-extensions. It would be greatly beneficial if the python documentation could include the use of the Chrome Extension Python package I've developed. This package simplifies the process of using Chrome Extensions in Playwright to an great extent. Here's a brief example of using AdBlocker Extension:

    from playwright.sync_api import sync_playwright
    from chrome_extension_python import Extension
    import random
    
    def generate_random_profile():
        return str(random.randint(1, 1000))
    
    with sync_playwright() as p:
        extension_path = Extension("https://chromewebstore.google.com/detail/adblock-%E2%80%94-best-ad-blocker/gighmmpiobklfepjocnamgkkbiglidom").load(with_command_line_option=False)
        browser = p.chromium.launch_persistent_context(
            user_data_dir=generate_random_profile(),
            headless=False,
            args=[
                '--disable-extensions-except='+ extension_path,
                '--load-extension=' + extension_path,
            ],
        )
        page = browser.new_page()
        input("Press Enter to exit...")
        browser.close()

Do you think others might benefit from this as well?

  • Absolutely, yes. The primary advantage of this package is its simplicity. Users can integrate any Chrome Extension into their Playwright project with just one line of code, eliminating the cumbersome process of manual downloading, unzipping, and using extensions. This improvement would not only enhance user experience but also streamline the process of browser automation for many Playwright users.

Also, You can learn about the package here.

Thank you, for considering my suggestion.

@mxschmitt
Copy link
Member

We appreciate the suggestion and effort of you creating this package. We try to keep our dependencies and software we recommend small and make sure that the projects are backed by multiple maintainers / already gained popularity. Using a extension is usually a niece use-case. I recommend writing a few blog posts first about it, so it ends up on Google and users can try it out.

@Chetan11-dev
Copy link
Author

Chetan11-dev commented Feb 1, 2024

Thank you for your response. I'd like to suggest that there's no need to bundle the extension with Playwright. Instead, you could simply include instructions in Docs to:

  1. Install the library.
  2. Use it.

Additionally, the library is a standalone file without any external dependencies. You can review the source here. Drawing from my personal experience in developing the Web Scraping Library Botasaurus, which has garnered 349 stars, I can attest to its utility. For instance, it offers customization options such as solving captchas, as outlined here.

It will occupy just a few lines in your docs, but adding it to docs can significantly save hours of playwright user's time spent on tasks like downloading, unzipping, and configuring extensions.

I understand that as playwright developers, managing numerous feature requests can be overwhelming, but incorporating this change could genuinely save developers hours of effort.

You can discuss it's utility among maintainers in a discussion and in case you find it a good addition to docs you can add it.
Thanks!

@grayguest
Copy link

Let us know what functionality you'd like to see in Playwright and what your use case is?让我们知道您希望在 Playwright 中看到哪些功能以及您的用例是什么?

  • I would like to suggest an update for the Playwright documentation, specifically at https://playwright.dev/python/docs/chrome-extensions. It would be greatly beneficial if the python documentation could include the use of the Chrome Extension Python package I've developed. This package simplifies the process of using Chrome Extensions in Playwright to an great extent. Here's a brief example of using AdBlocker Extension:我想建议对 Playwright 文档进行更新,特别是在 https://playwright.dev/python/docs/chrome-extensions。如果 python 文档可以包括使用我开发的 Chrome 扩展 Python 包,那将是非常有益的。此软件包在很大程度上简化了在 Playwright 中使用 Chrome 扩展程序的过程。下面是使用 AdBlocker 扩展程序的简短示例:
    from playwright.sync_api import sync_playwright
    from chrome_extension_python import Extension
    import random
    
    def generate_random_profile():
        return str(random.randint(1, 1000))
    
    with sync_playwright() as p:
        extension_path = Extension("https://chromewebstore.google.com/detail/adblock-%E2%80%94-best-ad-blocker/gighmmpiobklfepjocnamgkkbiglidom").load(with_command_line_option=False)
        browser = p.chromium.launch_persistent_context(
            user_data_dir=generate_random_profile(),
            headless=False,
            args=[
                '--disable-extensions-except='+ extension_path,
                '--load-extension=' + extension_path,
            ],
        )
        page = browser.new_page()
        input("Press Enter to exit...")
        browser.close()

Do you think others might benefit from this as well?你认为其他人也会从中受益吗?

  • Absolutely, yes. The primary advantage of this package is its simplicity. Users can integrate any Chrome Extension into their Playwright project with just one line of code, eliminating the cumbersome process of manual downloading, unzipping, and using extensions. This improvement would not only enhance user experience but also streamline the process of browser automation for many Playwright users.绝对可以。该软件包的主要优点是其简单性。用户只需一行代码即可将任何 Chrome 扩展程序集成到他们的 Playwright 项目中,从而消除了手动下载、解压缩和使用扩展程序的繁琐过程。这一改进不仅可以增强用户体验,还可以简化许多 Playwright 用户的浏览器自动化过程。

Also, You can learn about the package here.另外,您可以在此处了解该软件包。

Thank you, for considering my suggestion.谢谢你考虑我的建议。

Sir, Is there any way to add new extensions to an instance of chrome that has been started?

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